summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorHarish Ved <ved.harish3@gmail.com>2018-05-17 16:20:41 +0000
committerRémy Coutable <remy@rymai.me>2018-05-17 16:20:41 +0000
commitb11c218ad9d4635c2230e7f8d105236ca32e5072 (patch)
treeb5902078050ac04390ca8642ae301db2b9056627 /db
parent47555ef85e2a138e5ac16bfff597b7e72f818b25 (diff)
downloadgitlab-ce-b11c218ad9d4635c2230e7f8d105236ca32e5072.tar.gz
Fix: Use case in-sensitive ordering by name for groups
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20180504195842_project_name_lower_index.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/db/migrate/20180504195842_project_name_lower_index.rb b/db/migrate/20180504195842_project_name_lower_index.rb
new file mode 100644
index 00000000000..d6f25d3d4ab
--- /dev/null
+++ b/db/migrate/20180504195842_project_name_lower_index.rb
@@ -0,0 +1,32 @@
+# See http://doc.gitlab.com/ce/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class ProjectNameLowerIndex < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+ INDEX_NAME = 'index_projects_on_lower_name'
+
+ disable_ddl_transaction!
+
+ def up
+ return unless Gitlab::Database.postgresql?
+
+ disable_statement_timeout
+
+ execute "CREATE INDEX CONCURRENTLY #{INDEX_NAME} ON projects (LOWER(name))"
+ end
+
+ def down
+ return unless Gitlab::Database.postgresql?
+
+ disable_statement_timeout
+
+ if supports_drop_index_concurrently?
+ execute "DROP INDEX CONCURRENTLY IF EXISTS #{INDEX_NAME}"
+ else
+ execute "DROP INDEX IF EXISTS #{INDEX_NAME}"
+ end
+ end
+end