2018-11-13 07:27:31 +00:00
|
|
|
class EnqueueDeleteDiffFilesWorkers < ActiveRecord::Migration[4.2]
|
2018-07-03 12:23:17 +00:00
|
|
|
include Gitlab::Database::MigrationHelpers
|
|
|
|
|
|
|
|
DOWNTIME = false
|
2018-07-09 21:34:30 +00:00
|
|
|
SCHEDULER = 'ScheduleDiffFilesDeletion'.freeze
|
2018-07-06 15:23:51 +00:00
|
|
|
TMP_INDEX = 'tmp_partial_diff_id_with_files_index'.freeze
|
2018-07-03 12:23:17 +00:00
|
|
|
|
|
|
|
disable_ddl_transaction!
|
|
|
|
|
|
|
|
def up
|
2018-07-06 15:23:51 +00:00
|
|
|
unless index_exists_by_name?(:merge_request_diffs, TMP_INDEX)
|
|
|
|
add_concurrent_index(:merge_request_diffs, :id, where: "(state NOT IN ('without_files', 'empty'))", name: TMP_INDEX)
|
|
|
|
end
|
|
|
|
|
2018-07-09 21:34:30 +00:00
|
|
|
BackgroundMigrationWorker.perform_async(SCHEDULER)
|
2018-07-06 15:23:51 +00:00
|
|
|
|
|
|
|
# We don't remove the index since it's going to be used on DeleteDiffFiles
|
|
|
|
# worker. We should remove it in an upcoming release.
|
2018-07-03 12:23:17 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
2018-07-06 15:23:51 +00:00
|
|
|
if index_exists_by_name?(:merge_request_diffs, TMP_INDEX)
|
|
|
|
remove_concurrent_index_by_name(:merge_request_diffs, TMP_INDEX)
|
|
|
|
end
|
2018-07-03 12:23:17 +00:00
|
|
|
end
|
|
|
|
end
|