diff options
author | Sean McGivern <sean@gitlab.com> | 2019-03-28 09:19:14 +0000 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2019-03-28 09:19:14 +0000 |
commit | 1ab4d12aae9897e48df054a7c58944c5c73a2759 (patch) | |
tree | 730ecd88e33b6514e4c1ff0020ab3a793c073004 /db | |
parent | fd3f70c3157da3fbf15c40c48c14c3feaaadcf86 (diff) | |
parent | 0e831b0b692f2988d3c84fc01a463b08afec05ad (diff) | |
download | gitlab-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')
-rw-r--r-- | db/migrate/20190222051615_add_indexes_for_merge_request_diffs_query.rb | 42 | ||||
-rw-r--r-- | db/schema.rb | 3 |
2 files changed, 45 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 diff --git a/db/schema.rb b/db/schema.rb index 06f9f5da10d..7cc09e56285 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1256,6 +1256,7 @@ ActiveRecord::Schema.define(version: 20190322132835) do t.integer "external_diff_store" t.boolean "stored_externally" t.index ["merge_request_id", "id"], name: "index_merge_request_diffs_on_merge_request_id_and_id", using: :btree + t.index ["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))", using: :btree end create_table "merge_request_metrics", force: :cascade do |t| @@ -1271,7 +1272,9 @@ ActiveRecord::Schema.define(version: 20190322132835) do t.integer "latest_closed_by_id" t.datetime_with_timezone "latest_closed_at" t.index ["first_deployed_to_production_at"], name: "index_merge_request_metrics_on_first_deployed_to_production_at", using: :btree + t.index ["latest_closed_at"], name: "index_merge_request_metrics_on_latest_closed_at", where: "(latest_closed_at IS NOT NULL)", using: :btree t.index ["latest_closed_by_id"], name: "index_merge_request_metrics_on_latest_closed_by_id", using: :btree + t.index ["merge_request_id", "merged_at"], name: "index_merge_request_metrics_on_merge_request_id_and_merged_at", where: "(merged_at IS NOT NULL)", using: :btree t.index ["merge_request_id"], name: "index_merge_request_metrics", using: :btree t.index ["merged_by_id"], name: "index_merge_request_metrics_on_merged_by_id", using: :btree t.index ["pipeline_id"], name: "index_merge_request_metrics_on_pipeline_id", using: :btree |