Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorJasper Maes <jaspermaes.jm@gmail.com>2018-06-02 13:46:08 +0300
committerJasper Maes <jaspermaes.jm@gmail.com>2018-06-05 09:06:35 +0300
commit85a7e0813e9806ad3eb853e4a48c09ae5f78f94c (patch)
treedb7d77148d74f600b4d7e79c568afd816b9f1b9a /db
parent800d3b88c78ee7a98fa41f3a1628c6c2a6d12a68 (diff)
Support rails5 in postgres indexes function and fix some migrations
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20160226114608_add_trigram_indexes_for_searching.rb7
-rw-r--r--db/migrate/20170622135728_add_unique_constraint_to_ci_variables.rb11
-rw-r--r--db/migrate/20171106155656_turn_issues_due_date_index_to_partial_index.rb6
-rw-r--r--db/migrate/20180201110056_add_foreign_keys_to_todos.rb2
4 files changed, 13 insertions, 13 deletions
diff --git a/db/migrate/20160226114608_add_trigram_indexes_for_searching.rb b/db/migrate/20160226114608_add_trigram_indexes_for_searching.rb
index 375e389e07a..7aa79bf5e02 100644
--- a/db/migrate/20160226114608_add_trigram_indexes_for_searching.rb
+++ b/db/migrate/20160226114608_add_trigram_indexes_for_searching.rb
@@ -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;")
row = res.first
- row && row['enabled'] == 't' ? true : false
+ check = if Gitlab.rails5?
+ true
+ else
+ 't'
+ end
+ row && row['enabled'] == check ? true : false
end
def create_trigrams_extension
diff --git a/db/migrate/20170622135728_add_unique_constraint_to_ci_variables.rb b/db/migrate/20170622135728_add_unique_constraint_to_ci_variables.rb
index 8b2cc40ee59..787022b7bfe 100644
--- a/db/migrate/20170622135728_add_unique_constraint_to_ci_variables.rb
+++ b/db/migrate/20170622135728_add_unique_constraint_to_ci_variables.rb
@@ -2,12 +2,13 @@ class AddUniqueConstraintToCiVariables < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
+ INDEX_NAME = 'index_ci_variables_on_project_id_and_key_and_environment_scope'
disable_ddl_transaction!
def up
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
@@ -18,21 +19,17 @@ class AddUniqueConstraintToCiVariables < ActiveRecord::Migration
add_concurrent_index(:ci_variables, :project_id)
end
- remove_concurrent_index(:ci_variables, columns, name: index_name)
+ remove_concurrent_index(:ci_variables, columns, name: INDEX_NAME)
end
end
private
def this_index_exists?
- index_exists?(:ci_variables, columns, name: index_name)
+ index_exists?(:ci_variables, columns, name: INDEX_NAME)
end
def columns
@columns ||= [:project_id, :key, :environment_scope]
end
-
- def index_name
- 'index_ci_variables_on_project_id_and_key_and_environment_scope'
- end
end
diff --git a/db/migrate/20171106155656_turn_issues_due_date_index_to_partial_index.rb b/db/migrate/20171106155656_turn_issues_due_date_index_to_partial_index.rb
index e4bed778695..08784de4043 100644
--- a/db/migrate/20171106155656_turn_issues_due_date_index_to_partial_index.rb
+++ b/db/migrate/20171106155656_turn_issues_due_date_index_to_partial_index.rb
@@ -20,9 +20,7 @@ class TurnIssuesDueDateIndexToPartialIndex < ActiveRecord::Migration
name: NEW_INDEX_NAME
)
- # We set the column name to nil as otherwise Rails will ignore the custom
- # index name and remove the wrong index.
- remove_concurrent_index(:issues, nil, name: OLD_INDEX_NAME)
+ remove_concurrent_index_by_name(:issues, OLD_INDEX_NAME)
end
def down
@@ -32,6 +30,6 @@ class TurnIssuesDueDateIndexToPartialIndex < ActiveRecord::Migration
name: OLD_INDEX_NAME
)
- remove_concurrent_index(:issues, nil, name: NEW_INDEX_NAME)
+ remove_concurrent_index_by_name(:issues, NEW_INDEX_NAME)
end
end
diff --git a/db/migrate/20180201110056_add_foreign_keys_to_todos.rb b/db/migrate/20180201110056_add_foreign_keys_to_todos.rb
index b7c40f8c01a..020b0550321 100644
--- a/db/migrate/20180201110056_add_foreign_keys_to_todos.rb
+++ b/db/migrate/20180201110056_add_foreign_keys_to_todos.rb
@@ -31,7 +31,7 @@ class AddForeignKeysToTodos < ActiveRecord::Migration
end
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, :notes
end