From 090ed087f0aba10dff142e48d97259fec28b89bb Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Wed, 21 Jun 2017 13:55:28 +0200 Subject: Bump build stage id reference migration identifier --- ...20170526185921_migrate_build_stage_reference.rb | 22 ++++++------------ ...26190000_migrate_build_stage_reference_again.rb | 27 ++++++++++++++++++++++ 2 files changed, 34 insertions(+), 15 deletions(-) create mode 100644 db/post_migrate/20170526190000_migrate_build_stage_reference_again.rb diff --git a/db/post_migrate/20170526185921_migrate_build_stage_reference.rb b/db/post_migrate/20170526185921_migrate_build_stage_reference.rb index d2e7fc207f0..98c32d8284c 100644 --- a/db/post_migrate/20170526185921_migrate_build_stage_reference.rb +++ b/db/post_migrate/20170526185921_migrate_build_stage_reference.rb @@ -3,25 +3,17 @@ class MigrateBuildStageReference < ActiveRecord::Migration DOWNTIME = false - disable_ddl_transaction! + ## + # This is an empty migration, content has been moved to a new one: + # post migrate 20170526190000 MigrateBuildStageReferenceAgain + # + # See gitlab-org/gitlab-ce!12337 for more details. def up - disable_statement_timeout - - stage_id = Arel.sql <<-SQL.strip_heredoc - (SELECT id FROM ci_stages - WHERE ci_stages.pipeline_id = ci_builds.commit_id - AND ci_stages.name = ci_builds.stage) - SQL - - update_column_in_batches(:ci_builds, :stage_id, stage_id) do |table, query| - query.where(table[:stage_id].eq(nil)) - end + # noop end def down - disable_statement_timeout - - update_column_in_batches(:ci_builds, :stage_id, nil) + # noop end end diff --git a/db/post_migrate/20170526190000_migrate_build_stage_reference_again.rb b/db/post_migrate/20170526190000_migrate_build_stage_reference_again.rb new file mode 100644 index 00000000000..97cb242415d --- /dev/null +++ b/db/post_migrate/20170526190000_migrate_build_stage_reference_again.rb @@ -0,0 +1,27 @@ +class MigrateBuildStageReferenceAgain < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + disable_statement_timeout + + stage_id = Arel.sql <<-SQL.strip_heredoc + (SELECT id FROM ci_stages + WHERE ci_stages.pipeline_id = ci_builds.commit_id + AND ci_stages.name = ci_builds.stage) + SQL + + update_column_in_batches(:ci_builds, :stage_id, stage_id) do |table, query| + query.where(table[:stage_id].eq(nil)) + end + end + + def down + disable_statement_timeout + + update_column_in_batches(:ci_builds, :stage_id, nil) + end +end -- cgit v1.2.1