diff options
author | Shinya Maeda <shinya@gitlab.com> | 2018-05-22 14:32:40 +0900 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2018-05-22 14:32:40 +0900 |
commit | f61666c0d70ed2d8457e4a8d8d23e68816498035 (patch) | |
tree | 67478ee365f1c1f652ed3f3e5e8c69eefe7a48ee /db | |
parent | 1c636b8080bad4f9ea8fb6992277e421816271ce (diff) | |
parent | c6f72ac9a88521257991aa9a0cc6d558126f5bb9 (diff) | |
download | gitlab-ce-f61666c0d70ed2d8457e4a8d8d23e68816498035.tar.gz |
Merge branch 'master' into per-project-pipeline-iid
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20180504195842_project_name_lower_index.rb | 32 |
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 |