Add Sprint relationships and constraints
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
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
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