summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2018-07-11 12:59:43 +0000
committerYorick Peterse <yorickpeterse@gmail.com>2018-07-11 12:59:43 +0000
commitd975a29be91fd8a6156d3d1446056b5f98412e95 (patch)
treea0440ddb62992c1577c2b962860b491dd9b7a606 /db
parentad604b52f2699c624187fd99d0d68bb3452a7a5c (diff)
parent659aeba43c498b7a45fb1495371ded7436b238c9 (diff)
downloadgitlab-ce-d975a29be91fd8a6156d3d1446056b5f98412e95.tar.gz
Merge branch 'add-back-mr-diff-deletion-migration' into 'master'
Add back MR diff deletion migration See merge request gitlab-org/gitlab-ce!20331
Diffstat (limited to 'db')
-rw-r--r--db/post_migrate/20180619121030_enqueue_delete_diff_files_workers.rb26
1 files changed, 26 insertions, 0 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
new file mode 100644
index 00000000000..c4d2f5f61a0
--- /dev/null
+++ b/db/post_migrate/20180619121030_enqueue_delete_diff_files_workers.rb
@@ -0,0 +1,26 @@
+class EnqueueDeleteDiffFilesWorkers < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ SCHEDULER = 'ScheduleDiffFilesDeletion'.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(SCHEDULER)
+
+ # 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
+ if index_exists_by_name?(:merge_request_diffs, TMP_INDEX)
+ remove_concurrent_index_by_name(:merge_request_diffs, TMP_INDEX)
+ end
+ end
+end