summaryrefslogtreecommitdiff
path: root/db/migrate
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2019-03-28 09:19:14 +0000
committerSean McGivern <sean@gitlab.com>2019-03-28 09:19:14 +0000
commit1ab4d12aae9897e48df054a7c58944c5c73a2759 (patch)
tree730ecd88e33b6514e4c1ff0020ab3a793c073004 /db/migrate
parentfd3f70c3157da3fbf15c40c48c14c3feaaadcf86 (diff)
parent0e831b0b692f2988d3c84fc01a463b08afec05ad (diff)
downloadgitlab-ce-1ab4d12aae9897e48df054a7c58944c5c73a2759.tar.gz
Merge branch '54670-external-diffs-when-outdated' into 'master'
Allow external diffs to be used conditionally Closes #54670 See merge request gitlab-org/gitlab-ce!25432
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/20190222051615_add_indexes_for_merge_request_diffs_query.rb42
1 files changed, 42 insertions, 0 deletions
diff --git a/db/migrate/20190222051615_add_indexes_for_merge_request_diffs_query.rb b/db/migrate/20190222051615_add_indexes_for_merge_request_diffs_query.rb
new file mode 100644
index 00000000000..0048268ca6f
--- /dev/null
+++ b/db/migrate/20190222051615_add_indexes_for_merge_request_diffs_query.rb
@@ -0,0 +1,42 @@
+# frozen_string_literal: true
+
+class AddIndexesForMergeRequestDiffsQuery < ActiveRecord::Migration[5.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ INDEX_SPECS = [
+ [
+ :merge_request_metrics,
+ :latest_closed_at,
+ { where: 'latest_closed_at IS NOT NULL' }
+ ],
+ [
+ :merge_request_metrics,
+ [:merge_request_id, :merged_at],
+ { where: 'merged_at IS NOT NULL' }
+ ],
+ [
+ :merge_request_diffs,
+ [:merge_request_id, :id],
+ {
+ name: 'index_merge_request_diffs_on_merge_request_id_and_id_partial',
+ where: 'NOT stored_externally OR stored_externally IS NULL'
+ }
+ ]
+ ].freeze
+
+ disable_ddl_transaction!
+
+ def up
+ INDEX_SPECS.each do |spec|
+ add_concurrent_index(*spec)
+ end
+ end
+
+ def down
+ INDEX_SPECS.reverse.each do |spec|
+ remove_concurrent_index(*spec)
+ end
+ end
+end