Skip to content

Remove non-null and uniqueness constraints for title from sprints

euko requested to merge 353350-constraints-on-title-for-sprints into master

What does this MR do and why?

Related to #353350 (closed)

Currently title is a required attribute for Iteration model (backed by sprints table) and we check title's uniqueness per project_id as well as iteraitons_cadence_id. In this MR we are removing these constraints from the DB while keeping their corresponding application-level checks to make the migrations reversible.

The removed DB constraints are:

  1. the non-null constraint for title
  2. index_sprints_on_iterations_cadence_id_and_title
  3. index_sprints_on_project_id_and_title(WHERE project_id IS NOT NULL)

*Note that no sprint record should be associated with any project. We scraped the plan to support project iterations without rolling out the feature to production but have not cleaned up the code afterwards:

gitlabhq_production=> SELECT COUNT(*) FROM sprints WHERE project_id IS NOT NULL;

 count 
-------
     0
(1 row)

Migration outputs

https://gitlab.com/gitlab-org/gitlab/-/jobs/2163006781

Query timings

(in case the migrations need to be reversed / ran on a dblab clone)

=# CREATE UNIQUE INDEX CONCURRENTLY "index_sprints_on_project_id_and_title" ON "sprints" ("project_id", "title") WHERE project_id IS NOT NULL;
CREATE INDEX
Time: 459.824 ms

=# CREATE UNIQUE INDEX CONCURRENTLY "index_sprints_on_iterations_cadence_id_and_title" ON "sprints" ("iterations_cadence_id", "title");
CREATE INDEX
Time: 219.500 ms

=# ALTER TABLE "sprints" ALTER COLUMN "title" SET NOT NULL;
ALTER TABLE
Time: 160.699 ms

Also see !82169 (comment 862743145)

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by euko

Merge request reports

Loading