Skip to content

Add Sprint relationships and constraints

Mario de la Ossa requested to merge 205570-sprint_relationships into master

What does this MR do?

Adds Sprints to projects, groups, issues, and merge requests. Also adds foreign keys, some special constraints, etc.

Please note changes in this MR have received approval from frontend and DB from !25658 (closed)

Screenshots

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team

Database

Migrations up

== 20200304023245 AddSprintToIssues: migrating ================================
-- add_column(:issues, :sprint_id, :bigint)
   -> 0.0007s
== 20200304023245 AddSprintToIssues: migrated (0.0068s) =======================
== 20200304023851 AddSprintToMergeRequests: migrating =========================
-- add_column(:merge_requests, :sprint_id, :bigint)
   -> 0.0004s
== 20200304023851 AddSprintToMergeRequests: migrated (0.0014s) ================
== 20200304024025 AddSprintIdIndexToIssues: migrating =========================
-- transaction_open?()
   -> 0.0000s
-- index_exists?(:issues, :sprint_id, {:algorithm=>:concurrently})
   -> 0.0075s
-- execute("SET statement_timeout TO 0")
   -> 0.0001s
-- add_index(:issues, :sprint_id, {:algorithm=>:concurrently})
   -> 0.0023s
-- execute("RESET ALL")
   -> 0.0002s
-- transaction_open?()
   -> 0.0000s
-- foreign_keys(:issues)
   -> 0.0030s
-- execute("ALTER TABLE issues\nADD CONSTRAINT fk_3b8c72ea56\nFOREIGN KEY (sprint_id)\nREFERENCES sprints (id)\nON DELETE CASCADE\nNOT VALID;\n")
   -> 0.0011s
-- execute("SET statement_timeout TO 0")
   -> 0.0002s
-- execute("ALTER TABLE issues VALIDATE CONSTRAINT fk_3b8c72ea56;")
   -> 0.0028s
-- execute("RESET ALL")
   -> 0.0001s
== 20200304024025 AddSprintIdIndexToIssues: migrated (0.0178s) ================
== 20200304024042 AddSprintIdIndexToMergeRequests: migrating ==================
-- transaction_open?()
   -> 0.0000s
-- index_exists?(:merge_requests, :sprint_id, {:algorithm=>:concurrently})
   -> 0.0076s
-- execute("SET statement_timeout TO 0")
   -> 0.0001s
-- add_index(:merge_requests, :sprint_id, {:algorithm=>:concurrently})
   -> 0.0025s
-- execute("RESET ALL")
   -> 0.0002s
-- transaction_open?()
   -> 0.0000s
-- foreign_keys(:merge_requests)
   -> 0.0023s
-- execute("ALTER TABLE merge_requests\nADD CONSTRAINT fk_7e85395a64\nFOREIGN KEY (sprint_id)\nREFERENCES sprints (id)\nON DELETE CASCADE\nNOT VALID;\n")
   -> 0.0007s
-- execute("SET statement_timeout TO 0")
   -> 0.0001s
-- execute("ALTER TABLE merge_requests VALIDATE CONSTRAINT fk_7e85395a64;")
   -> 0.0022s
-- execute("RESET ALL")
   -> 0.0002s
== 20200304024042 AddSprintIdIndexToMergeRequests: migrated (0.0162s) =========
== 20200420201933 AddCheckConstraintToSprintMustBelongToProjectOrGroup: migrating
-- transaction_open?()
   -> 0.0000s
-- execute("ALTER TABLE sprints\nADD CONSTRAINT sprints_must_belong_to_project_or_group\nCHECK ( (project_id != NULL AND group_id IS NULL) OR (group_id != NULL AND project_id IS NULL) )\nNOT VALID;\n")
   -> 0.0005s
-- execute("SET statement_timeout TO 0")
   -> 0.0002s
-- execute("ALTER TABLE sprints VALIDATE CONSTRAINT sprints_must_belong_to_project_or_group;")
   -> 0.0006s
-- execute("RESET ALL")
   -> 0.0002s
== 20200420201933 AddCheckConstraintToSprintMustBelongToProjectOrGroup: migrated (0.0037s)

Migrations down

== 20200420201933 AddCheckConstraintToSprintMustBelongToProjectOrGroup: reverting
-- execute("ALTER TABLE sprints\nDROP CONSTRAINT IF EXISTS sprints_must_belong_to_project_or_group\n")
   -> 0.0008s
== 20200420201933 AddCheckConstraintToSprintMustBelongToProjectOrGroup: reverted (0.0081s)
== 20200304024042 AddSprintIdIndexToMergeRequests: reverting ==================
-- remove_foreign_key(:merge_requests, {:column=>:sprint_id})
   -> 0.0045s
-- transaction_open?()
   -> 0.0000s
-- index_exists?(:merge_requests, :sprint_id, {:algorithm=>:concurrently})
   -> 0.0096s
-- execute("SET statement_timeout TO 0")
   -> 0.0002s
-- remove_index(:merge_requests, {:algorithm=>:concurrently, :column=>:sprint_id})
   -> 0.0094s
-- execute("RESET ALL")
   -> 0.0002s
== 20200304024042 AddSprintIdIndexToMergeRequests: reverted (0.0240s) =========
== 20200304024025 AddSprintIdIndexToIssues: reverting =========================
-- remove_foreign_key(:issues, {:column=>:sprint_id})
   -> 0.0048s
-- transaction_open?()
   -> 0.0000s
-- index_exists?(:issues, :sprint_id, {:algorithm=>:concurrently})
   -> 0.0093s
-- execute("SET statement_timeout TO 0")
   -> 0.0002s
-- remove_index(:issues, {:algorithm=>:concurrently, :column=>:sprint_id})
   -> 0.0104s
-- execute("RESET ALL")
   -> 0.0002s
== 20200304024025 AddSprintIdIndexToIssues: reverted (0.0252s) ================
== 20200304023851 AddSprintToMergeRequests: reverting =========================
-- remove_column(:merge_requests, :sprint_id)
   -> 0.0012s
== 20200304023851 AddSprintToMergeRequests: reverted (0.0087s) ================
== 20200304023245 AddSprintToIssues: reverting ================================
-- remove_column(:issues, :sprint_id)
   -> 0.0011s
== 20200304023245 AddSprintToIssues: reverted (0.0081s) =======================

Refs #205570 (closed)

Edited by Mario de la Ossa

Merge request reports