diff options
author | Shinya Maeda <shinya@gitlab.com> | 2018-12-05 15:57:00 +0900 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2018-12-05 15:57:52 +0900 |
commit | e62bfc7817ec024645383a9661fe7e36c13c1e01 (patch) | |
tree | 04227bafe6859ddbf5760ff9d3e1dc5e404fcb10 /db | |
parent | 23d921989b66881a647afaeafec357f15293790a (diff) | |
download | gitlab-ce-e62bfc7817ec024645383a9661fe7e36c13c1e01.tar.gz |
Merge request pipelines
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20181119081539_add_merge_request_id_to_ci_pipelines.rb | 13 | ||||
-rw-r--r-- | db/migrate/20181120091639_add_foreign_key_to_ci_pipelines_merge_requests.rb | 22 | ||||
-rw-r--r-- | db/schema.rb | 3 |
3 files changed, 38 insertions, 0 deletions
diff --git a/db/migrate/20181119081539_add_merge_request_id_to_ci_pipelines.rb b/db/migrate/20181119081539_add_merge_request_id_to_ci_pipelines.rb new file mode 100644 index 00000000000..65476109c61 --- /dev/null +++ b/db/migrate/20181119081539_add_merge_request_id_to_ci_pipelines.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class AddMergeRequestIdToCiPipelines < ActiveRecord::Migration + DOWNTIME = false + + def up + add_column :ci_pipelines, :merge_request_id, :integer + end + + def down + remove_column :ci_pipelines, :merge_request_id, :integer + end +end diff --git a/db/migrate/20181120091639_add_foreign_key_to_ci_pipelines_merge_requests.rb b/db/migrate/20181120091639_add_foreign_key_to_ci_pipelines_merge_requests.rb new file mode 100644 index 00000000000..c2b5b239279 --- /dev/null +++ b/db/migrate/20181120091639_add_foreign_key_to_ci_pipelines_merge_requests.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +class AddForeignKeyToCiPipelinesMergeRequests < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_index :ci_pipelines, :merge_request_id + add_concurrent_foreign_key :ci_pipelines, :merge_requests, column: :merge_request_id, on_delete: :cascade + end + + def down + if foreign_key_exists?(:ci_pipelines, :merge_requests, column: :merge_request_id) + remove_foreign_key :ci_pipelines, :merge_requests + end + + remove_concurrent_index :ci_pipelines, :merge_request_id + end +end diff --git a/db/schema.rb b/db/schema.rb index d048be08d77..65a69c2850c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -474,7 +474,9 @@ ActiveRecord::Schema.define(version: 20181126153547) do t.boolean "protected" t.integer "failure_reason" t.integer "iid" + t.integer "merge_request_id" t.index ["auto_canceled_by_id"], name: "index_ci_pipelines_on_auto_canceled_by_id", using: :btree + t.index ["merge_request_id"], name: "index_ci_pipelines_on_merge_request_id", using: :btree t.index ["pipeline_schedule_id"], name: "index_ci_pipelines_on_pipeline_schedule_id", using: :btree t.index ["project_id", "iid"], name: "index_ci_pipelines_on_project_id_and_iid", unique: true, where: "(iid IS NOT NULL)", using: :btree t.index ["project_id", "ref", "status", "id"], name: "index_ci_pipelines_on_project_id_and_ref_and_status_and_id", using: :btree @@ -2292,6 +2294,7 @@ ActiveRecord::Schema.define(version: 20181126153547) do add_foreign_key "ci_pipeline_variables", "ci_pipelines", column: "pipeline_id", name: "fk_f29c5f4380", on_delete: :cascade add_foreign_key "ci_pipelines", "ci_pipeline_schedules", column: "pipeline_schedule_id", name: "fk_3d34ab2e06", on_delete: :nullify add_foreign_key "ci_pipelines", "ci_pipelines", column: "auto_canceled_by_id", name: "fk_262d4c2d19", on_delete: :nullify + add_foreign_key "ci_pipelines", "merge_requests", name: "fk_a23be95014", on_delete: :cascade add_foreign_key "ci_pipelines", "projects", name: "fk_86635dbd80", on_delete: :cascade add_foreign_key "ci_runner_namespaces", "ci_runners", column: "runner_id", on_delete: :cascade add_foreign_key "ci_runner_namespaces", "namespaces", on_delete: :cascade |