diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-02-20 13:53:54 +0100 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-02-20 14:00:03 +0100 |
commit | 2f3f9a6bb0b4777146eb1ccc33ba14910cbd4746 (patch) | |
tree | 896fcd26f27efd0b630b981aa6dcc22ba2354726 /db/post_migrate | |
parent | 2d027056f9c56ad733bcccf54c3b7cf8c7cb95bf (diff) | |
download | gitlab-ce-2f3f9a6bb0b4777146eb1ccc33ba14910cbd4746.tar.gz |
Separate adding and removing index from stages migration
Diffstat (limited to 'db/post_migrate')
3 files changed, 28 insertions, 5 deletions
diff --git a/db/post_migrate/20180212101828_add_tmp_partial_null_index_to_builds.rb b/db/post_migrate/20180212101828_add_tmp_partial_null_index_to_builds.rb new file mode 100644 index 00000000000..df62ddf36c7 --- /dev/null +++ b/db/post_migrate/20180212101828_add_tmp_partial_null_index_to_builds.rb @@ -0,0 +1,14 @@ +class AddTmpPartialNullIndexToBuilds < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + disable_ddl_transaction! + + def up + add_concurrent_index(:ci_builds, :stage_id, where: 'stage_id IS NULL', + name: 'tmp_stage_id_partial_null_index') + end + + def down + remove_concurrent_index_by_name(:ci_builds, 'tmp_stage_id_partial_null_index') + end +end diff --git a/db/post_migrate/20180212101928_schedule_build_stage_migration.rb b/db/post_migrate/20180212101928_schedule_build_stage_migration.rb index f42a09f2223..df15b2cd9d4 100644 --- a/db/post_migrate/20180212101928_schedule_build_stage_migration.rb +++ b/db/post_migrate/20180212101928_schedule_build_stage_migration.rb @@ -15,17 +15,12 @@ class ScheduleBuildStageMigration < ActiveRecord::Migration def up disable_statement_timeout - add_concurrent_index(:ci_builds, :stage_id, where: 'stage_id IS NULL', - name: 'tmp_stage_id_partial_null_index') - Build.where('stage_id IS NULL').tap do |relation| queue_background_migration_jobs_by_range_at_intervals(relation, MIGRATION, 5.minutes, batch_size: BATCH_SIZE) end - - remove_concurrent_index_by_name(:ci_builds, 'tmp_stage_id_partial_null_index') end def down diff --git a/db/post_migrate/20180212102028_remove_tmp_partial_null_index_from_builds.rb b/db/post_migrate/20180212102028_remove_tmp_partial_null_index_from_builds.rb new file mode 100644 index 00000000000..139097399a6 --- /dev/null +++ b/db/post_migrate/20180212102028_remove_tmp_partial_null_index_from_builds.rb @@ -0,0 +1,14 @@ +class RemoveTmpPartialNullIndexFromBuilds < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + disable_ddl_transaction! + + def up + remove_concurrent_index_by_name(:ci_builds, 'tmp_stage_id_partial_null_index') + end + + def down + add_concurrent_index(:ci_builds, :stage_id, where: 'stage_id IS NULL', + name: 'tmp_stage_id_partial_null_index') + end +end |