diff options
author | Shinya Maeda <shinya@gitlab.com> | 2019-04-18 18:15:40 +0700 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2019-05-06 15:12:41 +0700 |
commit | 827fc3ccb9335aa29fba0fc532b70015ec4c5186 (patch) | |
tree | 5ac47dfb716d56e4b8d6bf7cfbadf7ba01845fdd /db | |
parent | 9aa81c0a95b0e54bbafca4755e95f27ee1eeb759 (diff) | |
download | gitlab-ce-827fc3ccb9335aa29fba0fc532b70015ec4c5186.tar.gz |
Create ActiveRecordModel and table for Merge Train feature
This database table and AR model is going to be used for
the merge train feature.
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20190418182545_create_merge_request_trains_table.rb | 18 | ||||
-rw-r--r-- | db/schema.rb | 14 |
2 files changed, 32 insertions, 0 deletions
diff --git a/db/migrate/20190418182545_create_merge_request_trains_table.rb b/db/migrate/20190418182545_create_merge_request_trains_table.rb new file mode 100644 index 00000000000..ac927c9c6b9 --- /dev/null +++ b/db/migrate/20190418182545_create_merge_request_trains_table.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class CreateMergeRequestTrainsTable < ActiveRecord::Migration[5.1] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + create_table :merge_trains, id: :bigserial do |t| + t.references :merge_request, foreign_key: { on_delete: :cascade }, type: :integer, index: false, null: false + t.references :user, foreign_key: { on_delete: :cascade }, type: :integer, null: false + t.references :pipeline, foreign_key: { to_table: :ci_pipelines, on_delete: :nullify }, type: :integer + t.timestamps_with_timezone null: false + + t.index [:merge_request_id], unique: true + end + end +end diff --git a/db/schema.rb b/db/schema.rb index de9e6f0b40d..ef8cb4abf31 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1361,6 +1361,17 @@ ActiveRecord::Schema.define(version: 20190426180107) do t.index ["merge_request_id"], name: "index_merge_requests_closing_issues_on_merge_request_id", using: :btree end + create_table "merge_trains", force: :cascade do |t| + t.integer "merge_request_id", null: false + t.integer "user_id", null: false + t.integer "pipeline_id" + t.datetime_with_timezone "created_at", null: false + t.datetime_with_timezone "updated_at", null: false + t.index ["merge_request_id"], name: "index_merge_trains_on_merge_request_id", unique: true, using: :btree + t.index ["pipeline_id"], name: "index_merge_trains_on_pipeline_id", using: :btree + t.index ["user_id"], name: "index_merge_trains_on_user_id", using: :btree + end + create_table "milestones", id: :serial, force: :cascade do |t| t.string "title", null: false t.integer "project_id" @@ -2514,6 +2525,9 @@ ActiveRecord::Schema.define(version: 20190426180107) do add_foreign_key "merge_requests", "users", column: "updated_by_id", name: "fk_641731faff", on_delete: :nullify add_foreign_key "merge_requests_closing_issues", "issues", on_delete: :cascade add_foreign_key "merge_requests_closing_issues", "merge_requests", on_delete: :cascade + add_foreign_key "merge_trains", "ci_pipelines", column: "pipeline_id", on_delete: :nullify + add_foreign_key "merge_trains", "merge_requests", on_delete: :cascade + add_foreign_key "merge_trains", "users", on_delete: :cascade add_foreign_key "milestones", "namespaces", column: "group_id", name: "fk_95650a40d4", on_delete: :cascade add_foreign_key "milestones", "projects", name: "fk_9bd0a0c791", on_delete: :cascade add_foreign_key "note_diff_files", "notes", column: "diff_note_id", on_delete: :cascade |