diff options
author | Rémy Coutable <remy@rymai.me> | 2017-05-19 17:13:37 +0000 |
---|---|---|
committer | Clement Ho <ClemMakesApps@gmail.com> | 2017-05-22 16:27:58 -0500 |
commit | 8fcfc492aec442be7d117d7751277fe53ad421f2 (patch) | |
tree | b81d3c10445e6625516e00a75d79fc946718ecbd | |
parent | 7727f193a16b1b272a75b466bb20e80c0797c552 (diff) | |
download | gitlab-ce-9-2-stable-fix-conflicts-for-partial-index.tar.gz |
Merge branch 'update-retried-migration' into 'master'9-2-stable-fix-conflicts-for-partial-index
Add temporary partial index to speed up the migration
Closes #32469
See merge request !11534
-rw-r--r-- | db/post_migrate/20170503004427_upate_retried_for_ci_build.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/db/post_migrate/20170503004427_upate_retried_for_ci_build.rb b/db/post_migrate/20170503004427_upate_retried_for_ci_build.rb index 3096c54acb7..0f81ad4b95a 100644 --- a/db/post_migrate/20170503004427_upate_retried_for_ci_build.rb +++ b/db/post_migrate/20170503004427_upate_retried_for_ci_build.rb @@ -8,6 +8,7 @@ class UpateRetriedForCiBuild < ActiveRecord::Migration def up disable_statement_timeout +<<<<<<< HEAD if Gitlab::Database.mysql? up_mysql else @@ -34,6 +35,8 @@ class UpateRetriedForCiBuild < ActiveRecord::Migration end def up_postgres +======= +>>>>>>> 27eab8a... Merge branch 'update-retried-migration' into 'master' with_temporary_partial_index do latest_id = <<-SQL.strip_heredoc SELECT MAX(ci_builds2.id) @@ -63,4 +66,16 @@ class UpateRetriedForCiBuild < ActiveRecord::Migration execute 'DROP INDEX CONCURRENTLY IF EXISTS index_for_ci_builds_retried_migration' end end + + def with_temporary_partial_index + if Gitlab::Database.postgresql? + execute 'CREATE INDEX CONCURRENTLY IF NOT EXISTS index_for_ci_builds_retried_migration ON ci_builds (id) WHERE retried IS NULL;' + end + + yield + + if Gitlab::Database.postgresql? + execute 'DROP INDEX CONCURRENTLY IF EXISTS index_for_ci_builds_retried_migration' + end + end end |