Commit 2f3f9a6b authored by Grzegorz Bizon's avatar Grzegorz Bizon

Separate adding and removing index from stages migration

parent 2d027056
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
......@@ -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
......
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
......@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20180212101928) do
ActiveRecord::Schema.define(version: 20180212102028) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment