debian-mirror-gitlab/db/post_migrate/20220505044348_fix_automatic_iterations_cadences_start_date.rb
2022-07-16 19:58:13 +02:00

29 lines
760 B
Ruby

# frozen_string_literal: true
class FixAutomaticIterationsCadencesStartDate < Gitlab::Database::Migration[2.0]
restrict_gitlab_migration gitlab_schema: :gitlab_main
def up
execute(<<~SQL)
UPDATE iterations_cadences
SET start_date=COALESCE(
(
SELECT start_date
FROM sprints
WHERE iterations_cadences.id=sprints.iterations_cadence_id
ORDER BY sprints.start_date ASC
LIMIT 1
),
start_date
)
WHERE iterations_cadences.automatic=true;
SQL
end
def down
# no-op
# The migration updates the records for the feature used behind a non-default feature flag.
# The correct data can be computed with the records from 'sprints' table.
end
end