summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--db/post_migrate/20170503004427_upate_retried_for_ci_build.rb15
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