Fix invalid cadence start dates
This MR contains a DB migration to fix a small number of records from iterations_cadences
table which represents domain objects "iteration cadences".
An iterations cadence can have many iterations. We now require the start date of an iterations cadence to match that of its first iteration (when sorted by start date ASC.) This requirement is only validated for iterations cadences that are automatic (automatic
column is true
.) Because we allowed a cadence's start date to be freely updated up until recently, we want to fix the iterations cadences records that have invalid start dates through a DB migration.
Iterations cadences records affected are behind a non-default feature flag iteration_cadences
and the count of records affected by the migration is 37
. iterations_cadences
table has about 4000 records as of May 5, 2022.
Query plan
QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Update on iterations_cadences (cost=0.00..684.39 rows=37 width=84) (actual time=2.008..2.010 rows=0 loops=1)
Buffers: shared hit=704 dirtied=28
-> Seq Scan on iterations_cadences (cost=0.00..684.39 rows=37 width=84) (actual time=0.294..1.456 rows=37 loops=1)
Filter: automatic
Rows Removed by Filter: 3992
Buffers: shared hit=459
SubPlan 1
-> Limit (cost=10.92..10.92 rows=1 width=4) (actual time=0.022..0.022 rows=1 loops=37)
Buffers: shared hit=399
-> Sort (cost=10.92..10.94 rows=6 width=4) (actual time=0.021..0.021 rows=1 loops=37)
Sort Key: sprints.start_date
Sort Method: top-N heapsort Memory: 25kB
Buffers: shared hit=399
-> Index Scan using index_sprints_iterations_cadence_id on sprints (cost=0.29..10.89 rows=6 width=4) (actual time=0.005..0.018 rows=16 loops=37)
Index Cond: (iterations_cadence_id = iterations_cadences.id)
Buffers: shared hit=399
Planning Time: 0.305 ms
Execution Time: 2.070 ms
(18 rows)
Related to #354977 (closed). Please see the discussions in #354977 (comment 911801590) for more context.