diff options
author | Oswaldo Ferreira <oswaldo@gitlab.com> | 2018-07-06 18:23:51 +0300 |
---|---|---|
committer | Oswaldo Ferreira <oswaldo@gitlab.com> | 2018-07-10 15:43:58 +0300 |
commit | db0f150516404c6e7951bc961eab45be11b5fcf5 (patch) | |
tree | 74792807be2e5b7d44740ee50ddcdd57e6e9c180 /db/post_migrate | |
parent | 19966e7095fd6357183afb8e009c7f8e78a05591 (diff) |
Reschedule DeleteDiffFiles until there is none left to remove
Diffstat (limited to 'db/post_migrate')
-rw-r--r-- | db/post_migrate/20180619121030_enqueue_delete_diff_files_workers.rb | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/db/post_migrate/20180619121030_enqueue_delete_diff_files_workers.rb b/db/post_migrate/20180619121030_enqueue_delete_diff_files_workers.rb index 9e96aaf50a0..100bd2a8f4e 100644 --- a/db/post_migrate/20180619121030_enqueue_delete_diff_files_workers.rb +++ b/db/post_migrate/20180619121030_enqueue_delete_diff_files_workers.rb @@ -3,14 +3,24 @@ class EnqueueDeleteDiffFilesWorkers < ActiveRecord::Migration DOWNTIME = false MIGRATION = 'DeleteDiffFiles'.freeze + TMP_INDEX = 'tmp_partial_diff_id_with_files_index'.freeze disable_ddl_transaction! def up + 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 + BackgroundMigrationWorker.perform_async(MIGRATION) + + # We don't remove the index since it's going to be used on DeleteDiffFiles + # worker. We should remove it in an upcoming release. end def down - # no-op + if index_exists_by_name?(:merge_request_diffs, TMP_INDEX) + remove_concurrent_index_by_name(:merge_request_diffs, TMP_INDEX) + end end end |