Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
85a7e081
Commit
85a7e081
authored
Jun 02, 2018
by
Jasper Maes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support rails5 in postgres indexes function and fix some migrations
parent
800d3b88
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
26 additions
and
14 deletions
+26
-14
changelogs/unreleased/rails5-fix-46236.yml
changelogs/unreleased/rails5-fix-46236.yml
+5
-0
config/initializers/postgresql_opclasses_support.rb
config/initializers/postgresql_opclasses_support.rb
+8
-1
db/migrate/20160226114608_add_trigram_indexes_for_searching.rb
...grate/20160226114608_add_trigram_indexes_for_searching.rb
+6
-1
db/migrate/20170622135728_add_unique_constraint_to_ci_variables.rb
...e/20170622135728_add_unique_constraint_to_ci_variables.rb
+4
-7
db/migrate/20171106155656_turn_issues_due_date_index_to_partial_index.rb
...1106155656_turn_issues_due_date_index_to_partial_index.rb
+2
-4
db/migrate/20180201110056_add_foreign_keys_to_todos.rb
db/migrate/20180201110056_add_foreign_keys_to_todos.rb
+1
-1
No files found.
changelogs/unreleased/rails5-fix-46236.yml
0 → 100644
View file @
85a7e081
---
title
:
Support rails5 in postgres indexes function and fix some migrations
merge_request
:
19400
author
:
Jasper Maes
type
:
fixed
config/initializers/postgresql_opclasses_support.rb
View file @
85a7e081
...
@@ -107,8 +107,15 @@ module ActiveRecord
...
@@ -107,8 +107,15 @@ module ActiveRecord
result
.
map
do
|
row
|
result
.
map
do
|
row
|
index_name
=
row
[
0
]
index_name
=
row
[
0
]
unique
=
row
[
1
]
==
't'
unique
=
if
Gitlab
.
rails5?
row
[
1
]
else
row
[
1
]
==
't'
end
indkey
=
row
[
2
].
split
(
" "
)
indkey
=
row
[
2
].
split
(
" "
)
if
Gitlab
.
rails5?
indkey
=
indkey
.
map
(
&
:to_i
)
end
inddef
=
row
[
3
]
inddef
=
row
[
3
]
oid
=
row
[
4
]
oid
=
row
[
4
]
...
...
db/migrate/20160226114608_add_trigram_indexes_for_searching.rb
View file @
85a7e081
...
@@ -37,7 +37,12 @@ class AddTrigramIndexesForSearching < ActiveRecord::Migration
...
@@ -37,7 +37,12 @@ class AddTrigramIndexesForSearching < ActiveRecord::Migration
res
=
execute
(
"SELECT true AS enabled FROM pg_available_extensions WHERE name = 'pg_trgm' AND installed_version IS NOT NULL;"
)
res
=
execute
(
"SELECT true AS enabled FROM pg_available_extensions WHERE name = 'pg_trgm' AND installed_version IS NOT NULL;"
)
row
=
res
.
first
row
=
res
.
first
row
&&
row
[
'enabled'
]
==
't'
?
true
:
false
check
=
if
Gitlab
.
rails5?
true
else
't'
end
row
&&
row
[
'enabled'
]
==
check
?
true
:
false
end
end
def
create_trigrams_extension
def
create_trigrams_extension
...
...
db/migrate/20170622135728_add_unique_constraint_to_ci_variables.rb
View file @
85a7e081
...
@@ -2,12 +2,13 @@ class AddUniqueConstraintToCiVariables < ActiveRecord::Migration
...
@@ -2,12 +2,13 @@ class AddUniqueConstraintToCiVariables < ActiveRecord::Migration
include
Gitlab
::
Database
::
MigrationHelpers
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
DOWNTIME
=
false
INDEX_NAME
=
'index_ci_variables_on_project_id_and_key_and_environment_scope'
disable_ddl_transaction!
disable_ddl_transaction!
def
up
def
up
unless
this_index_exists?
unless
this_index_exists?
add_concurrent_index
(
:ci_variables
,
columns
,
name:
index_name
,
unique:
true
)
add_concurrent_index
(
:ci_variables
,
columns
,
name:
INDEX_NAME
,
unique:
true
)
end
end
end
end
...
@@ -18,21 +19,17 @@ class AddUniqueConstraintToCiVariables < ActiveRecord::Migration
...
@@ -18,21 +19,17 @@ class AddUniqueConstraintToCiVariables < ActiveRecord::Migration
add_concurrent_index
(
:ci_variables
,
:project_id
)
add_concurrent_index
(
:ci_variables
,
:project_id
)
end
end
remove_concurrent_index
(
:ci_variables
,
columns
,
name:
index_name
)
remove_concurrent_index
(
:ci_variables
,
columns
,
name:
INDEX_NAME
)
end
end
end
end
private
private
def
this_index_exists?
def
this_index_exists?
index_exists?
(
:ci_variables
,
columns
,
name:
index_name
)
index_exists?
(
:ci_variables
,
columns
,
name:
INDEX_NAME
)
end
end
def
columns
def
columns
@columns
||=
[
:project_id
,
:key
,
:environment_scope
]
@columns
||=
[
:project_id
,
:key
,
:environment_scope
]
end
end
def
index_name
'index_ci_variables_on_project_id_and_key_and_environment_scope'
end
end
end
db/migrate/20171106155656_turn_issues_due_date_index_to_partial_index.rb
View file @
85a7e081
...
@@ -20,9 +20,7 @@ class TurnIssuesDueDateIndexToPartialIndex < ActiveRecord::Migration
...
@@ -20,9 +20,7 @@ class TurnIssuesDueDateIndexToPartialIndex < ActiveRecord::Migration
name:
NEW_INDEX_NAME
name:
NEW_INDEX_NAME
)
)
# We set the column name to nil as otherwise Rails will ignore the custom
remove_concurrent_index_by_name
(
:issues
,
OLD_INDEX_NAME
)
# index name and remove the wrong index.
remove_concurrent_index
(
:issues
,
nil
,
name:
OLD_INDEX_NAME
)
end
end
def
down
def
down
...
@@ -32,6 +30,6 @@ class TurnIssuesDueDateIndexToPartialIndex < ActiveRecord::Migration
...
@@ -32,6 +30,6 @@ class TurnIssuesDueDateIndexToPartialIndex < ActiveRecord::Migration
name:
OLD_INDEX_NAME
name:
OLD_INDEX_NAME
)
)
remove_concurrent_index
(
:issues
,
nil
,
name:
NEW_INDEX_NAME
)
remove_concurrent_index
_by_name
(
:issues
,
NEW_INDEX_NAME
)
end
end
end
end
db/migrate/20180201110056_add_foreign_keys_to_todos.rb
View file @
85a7e081
...
@@ -31,7 +31,7 @@ class AddForeignKeysToTodos < ActiveRecord::Migration
...
@@ -31,7 +31,7 @@ class AddForeignKeysToTodos < ActiveRecord::Migration
end
end
def
down
def
down
remove_foreign_key
:todos
,
:users
remove_foreign_key
:todos
,
column: :user_id
remove_foreign_key
:todos
,
column: :author_id
remove_foreign_key
:todos
,
column: :author_id
remove_foreign_key
:todos
,
:notes
remove_foreign_key
:todos
,
:notes
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment