summaryrefslogtreecommitdiff
path: root/db/migrate
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2019-06-11 16:34:02 +0700
committerShinya Maeda <shinya@gitlab.com>2019-06-11 18:48:52 +0700
commitabcbeae9a72b393ea7c91bc74586b8359c7e3950 (patch)
tree1d26265ffad0dd89ea0925adb0aa0e5d67579cb3 /db/migrate
parentc327d02bd2e0e6b96c3c8448e043040914590b4d (diff)
downloadgitlab-ce-abcbeae9a72b393ea7c91bc74586b8359c7e3950.tar.gz
Persist target project id and target branch in merge trains table
In order to optimize the query performance, we should use target project id and target branch intead of cross-joining merge_requests table. Fix schema Fix schema
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/20190611161641_add_target_project_id_to_merge_trains.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/db/migrate/20190611161641_add_target_project_id_to_merge_trains.rb b/db/migrate/20190611161641_add_target_project_id_to_merge_trains.rb
new file mode 100644
index 00000000000..c200208e4c3
--- /dev/null
+++ b/db/migrate/20190611161641_add_target_project_id_to_merge_trains.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+class AddTargetProjectIdToMergeTrains < ActiveRecord::Migration[5.1]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def change
+ # rubocop: disable Rails/NotNullColumn
+ add_reference :merge_trains, :target_project, null: false, index: true, foreign_key: { on_delete: :cascade, to_table: :projects }, type: :integer
+ add_column :merge_trains, :target_branch, :text, null: false
+ # rubocop: enable Rails/NotNullColumn
+ end
+end