diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-14 09:09:03 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-14 09:09:03 +0300 |
commit | 10213bf3b26c3c21f7683471d35d1cd052c41e9c (patch) | |
tree | 32d1c776e16f56e1fc7a2ad0d5550029c24a3473 /db | |
parent | c60a1173018e93e6bf433f87cb726adc979d1c8a (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r-- | db/post_migrate/20200213204737_remove_unnecessary_milestone_join_tables.rb | 30 | ||||
-rw-r--r-- | db/schema.rb | 22 |
2 files changed, 31 insertions, 21 deletions
diff --git a/db/post_migrate/20200213204737_remove_unnecessary_milestone_join_tables.rb b/db/post_migrate/20200213204737_remove_unnecessary_milestone_join_tables.rb new file mode 100644 index 00000000000..19b3af53836 --- /dev/null +++ b/db/post_migrate/20200213204737_remove_unnecessary_milestone_join_tables.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class RemoveUnnecessaryMilestoneJoinTables < ActiveRecord::Migration[6.0] + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + def up + drop_table :issue_milestones + drop_table :merge_request_milestones + end + + def down + create_table :issue_milestones, id: false do |t| + t.references :issue, foreign_key: { on_delete: :cascade }, index: { unique: true }, null: false + t.references :milestone, foreign_key: { on_delete: :cascade }, index: true, null: false + end + + add_index :issue_milestones, [:issue_id, :milestone_id], unique: true + + create_table :merge_request_milestones, id: false do |t| + t.references :merge_request, foreign_key: { on_delete: :cascade }, index: { unique: true }, null: false + t.references :milestone, foreign_key: { on_delete: :cascade }, index: true, null: false + end + + add_index :merge_request_milestones, [:merge_request_id, :milestone_id], name: 'index_mrs_milestones_on_mr_id_and_milestone_id', unique: true + end +end diff --git a/db/schema.rb b/db/schema.rb index fc30081cedf..178a5c299bc 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2020_02_12_052620) do +ActiveRecord::Schema.define(version: 2020_02_13_204737) do # These are extensions that must be enabled in order to support this database enable_extension "pg_trgm" @@ -2125,14 +2125,6 @@ ActiveRecord::Schema.define(version: 2020_02_12_052620) do t.index ["issue_id"], name: "index_issue_metrics" end - create_table "issue_milestones", id: false, force: :cascade do |t| - t.bigint "issue_id", null: false - t.bigint "milestone_id", null: false - t.index ["issue_id", "milestone_id"], name: "index_issue_milestones_on_issue_id_and_milestone_id", unique: true - t.index ["issue_id"], name: "index_issue_milestones_on_issue_id", unique: true - t.index ["milestone_id"], name: "index_issue_milestones_on_milestone_id" - end - create_table "issue_tracker_data", force: :cascade do |t| t.integer "service_id", null: false t.datetime_with_timezone "created_at", null: false @@ -2552,14 +2544,6 @@ ActiveRecord::Schema.define(version: 2020_02_12_052620) do t.index ["pipeline_id"], name: "index_merge_request_metrics_on_pipeline_id" end - create_table "merge_request_milestones", id: false, force: :cascade do |t| - t.bigint "merge_request_id", null: false - t.bigint "milestone_id", null: false - t.index ["merge_request_id", "milestone_id"], name: "index_mrs_milestones_on_mr_id_and_milestone_id", unique: true - t.index ["merge_request_id"], name: "index_merge_request_milestones_on_merge_request_id", unique: true - t.index ["milestone_id"], name: "index_merge_request_milestones_on_milestone_id" - end - create_table "merge_request_user_mentions", force: :cascade do |t| t.integer "merge_request_id", null: false t.integer "note_id" @@ -4799,8 +4783,6 @@ ActiveRecord::Schema.define(version: 2020_02_12_052620) do add_foreign_key "issue_links", "issues", column: "source_id", name: "fk_c900194ff2", on_delete: :cascade add_foreign_key "issue_links", "issues", column: "target_id", name: "fk_e71bb44f1f", on_delete: :cascade add_foreign_key "issue_metrics", "issues", on_delete: :cascade - add_foreign_key "issue_milestones", "issues", on_delete: :cascade - add_foreign_key "issue_milestones", "milestones", on_delete: :cascade add_foreign_key "issue_tracker_data", "services", on_delete: :cascade add_foreign_key "issue_user_mentions", "issues", on_delete: :cascade add_foreign_key "issue_user_mentions", "notes", on_delete: :cascade @@ -4846,8 +4828,6 @@ ActiveRecord::Schema.define(version: 2020_02_12_052620) do add_foreign_key "merge_request_metrics", "merge_requests", on_delete: :cascade add_foreign_key "merge_request_metrics", "users", column: "latest_closed_by_id", name: "fk_ae440388cc", on_delete: :nullify add_foreign_key "merge_request_metrics", "users", column: "merged_by_id", name: "fk_7f28d925f3", on_delete: :nullify - add_foreign_key "merge_request_milestones", "merge_requests", on_delete: :cascade - add_foreign_key "merge_request_milestones", "milestones", on_delete: :cascade add_foreign_key "merge_request_user_mentions", "merge_requests", on_delete: :cascade add_foreign_key "merge_request_user_mentions", "notes", on_delete: :cascade add_foreign_key "merge_requests", "ci_pipelines", column: "head_pipeline_id", name: "fk_fd82eae0b9", on_delete: :nullify |