diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-16 00:08:48 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-16 00:08:48 +0300 |
commit | 600ca978129e3ccab758f57d60786cefe66ad775 (patch) | |
tree | a3675da98c7c245adf7e93f82f9c26a38cc3c29d /db | |
parent | 571d993b49313dd806bd3f6af16d36c26d9d28ca (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
7 files changed, 133 insertions, 0 deletions
diff --git a/db/migrate/20191216074800_add_epic_date_sourcing_milestone_indexes.rb b/db/migrate/20191216074800_add_epic_date_sourcing_milestone_indexes.rb new file mode 100644 index 00000000000..72fd5937331 --- /dev/null +++ b/db/migrate/20191216074800_add_epic_date_sourcing_milestone_indexes.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +class AddEpicDateSourcingMilestoneIndexes < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_index :epics, due_date_column + add_concurrent_index :epics, start_date_column + end + + def down + remove_concurrent_index :epics, start_date_column + remove_concurrent_index :epics, due_date_column + end + + private + + def due_date_column + :due_date_sourcing_milestone_id + end + + def start_date_column + :start_date_sourcing_milestone_id + end +end diff --git a/db/migrate/20191216074802_add_epic_start_date_sourcing_milestone_id_foreign_key.rb b/db/migrate/20191216074802_add_epic_start_date_sourcing_milestone_id_foreign_key.rb new file mode 100644 index 00000000000..1c0713ec586 --- /dev/null +++ b/db/migrate/20191216074802_add_epic_start_date_sourcing_milestone_id_foreign_key.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +class AddEpicStartDateSourcingMilestoneIdForeignKey < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_foreign_key :epics, :milestones, column: start_date_column, on_delete: :nullify, validate: false + end + + def down + remove_foreign_key_if_exists :epics, column: start_date_column + end + + private + + def start_date_column + :start_date_sourcing_milestone_id + end +end diff --git a/db/migrate/20191216074803_add_epic_due_date_sourcing_milestone_id_foreign_key.rb b/db/migrate/20191216074803_add_epic_due_date_sourcing_milestone_id_foreign_key.rb new file mode 100644 index 00000000000..51202e358cc --- /dev/null +++ b/db/migrate/20191216074803_add_epic_due_date_sourcing_milestone_id_foreign_key.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +class AddEpicDueDateSourcingMilestoneIdForeignKey < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_foreign_key :epics, :milestones, column: due_date_column, on_delete: :nullify, validate: false + end + + def down + remove_foreign_key_if_exists :epics, column: due_date_column + end + + private + + def due_date_column + :due_date_sourcing_milestone_id + end +end diff --git a/db/migrate/20200110089001_fix_invalid_epic_sourcing_milestone_ids.rb b/db/migrate/20200110089001_fix_invalid_epic_sourcing_milestone_ids.rb new file mode 100644 index 00000000000..04f65c3a810 --- /dev/null +++ b/db/migrate/20200110089001_fix_invalid_epic_sourcing_milestone_ids.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +class FixInvalidEpicSourcingMilestoneIds < ActiveRecord::Migration[5.2] + DOWNTIME = false + + def up + nullify_invalid_data(:start_date_sourcing_milestone_id) + nullify_invalid_data(:due_date_sourcing_milestone_id) + end + + def down + # no-op + end + + private + + def nullify_invalid_data(column_name) + execute(<<-SQL.squish) + UPDATE epics + SET #{column_name} = null + WHERE #{column_name} NOT IN (SELECT id FROM milestones); + SQL + end +end diff --git a/db/migrate/20200110090153_validate_foreign_key_epic_start_date_sourcing_milestone.rb b/db/migrate/20200110090153_validate_foreign_key_epic_start_date_sourcing_milestone.rb new file mode 100644 index 00000000000..26ddf44cfeb --- /dev/null +++ b/db/migrate/20200110090153_validate_foreign_key_epic_start_date_sourcing_milestone.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class ValidateForeignKeyEpicStartDateSourcingMilestone < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + validate_foreign_key(:epics, :start_date_sourcing_milestone_id) + end + + def down + # no-op + end +end diff --git a/db/migrate/20200110203532_validate_foreign_key_epic_due_date_sourcing_milestone.rb b/db/migrate/20200110203532_validate_foreign_key_epic_due_date_sourcing_milestone.rb new file mode 100644 index 00000000000..2ff48715068 --- /dev/null +++ b/db/migrate/20200110203532_validate_foreign_key_epic_due_date_sourcing_milestone.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class ValidateForeignKeyEpicDueDateSourcingMilestone < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + validate_foreign_key(:epics, :due_date_sourcing_milestone_id) + end + + def down + # no-op + end +end diff --git a/db/schema.rb b/db/schema.rb index f6b815de8ba..0932993be24 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1573,6 +1573,7 @@ ActiveRecord::Schema.define(version: 2020_01_14_113341) do t.index ["author_id"], name: "index_epics_on_author_id" t.index ["closed_by_id"], name: "index_epics_on_closed_by_id" t.index ["due_date_sourcing_epic_id"], name: "index_epics_on_due_date_sourcing_epic_id", where: "(due_date_sourcing_epic_id IS NOT NULL)" + t.index ["due_date_sourcing_milestone_id"], name: "index_epics_on_due_date_sourcing_milestone_id" t.index ["end_date"], name: "index_epics_on_end_date" t.index ["group_id"], name: "index_epics_on_group_id" t.index ["iid"], name: "index_epics_on_iid" @@ -1580,6 +1581,7 @@ ActiveRecord::Schema.define(version: 2020_01_14_113341) do t.index ["parent_id"], name: "index_epics_on_parent_id" t.index ["start_date"], name: "index_epics_on_start_date" t.index ["start_date_sourcing_epic_id"], name: "index_epics_on_start_date_sourcing_epic_id", where: "(start_date_sourcing_epic_id IS NOT NULL)" + t.index ["start_date_sourcing_milestone_id"], name: "index_epics_on_start_date_sourcing_milestone_id" end create_table "events", id: :serial, force: :cascade do |t| @@ -4587,6 +4589,8 @@ ActiveRecord::Schema.define(version: 2020_01_14_113341) do add_foreign_key "epics", "epics", column: "due_date_sourcing_epic_id", name: "fk_013c9f36ca", on_delete: :nullify add_foreign_key "epics", "epics", column: "parent_id", name: "fk_25b99c1be3", on_delete: :cascade add_foreign_key "epics", "epics", column: "start_date_sourcing_epic_id", name: "fk_9d480c64b2", on_delete: :nullify + add_foreign_key "epics", "milestones", column: "due_date_sourcing_milestone_id", name: "fk_3c1fd1cccc", on_delete: :nullify + add_foreign_key "epics", "milestones", column: "start_date_sourcing_milestone_id", name: "fk_1fbed67632", on_delete: :nullify add_foreign_key "epics", "milestones", on_delete: :nullify add_foreign_key "epics", "namespaces", column: "group_id", name: "fk_f081aa4489", on_delete: :cascade add_foreign_key "epics", "users", column: "assignee_id", name: "fk_dccd3f98fc", on_delete: :nullify |