diff options
Diffstat (limited to 'db/migrate/20210127202613_remove_iteration_group_date_range_constraint.rb')
-rw-r--r-- | db/migrate/20210127202613_remove_iteration_group_date_range_constraint.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/db/migrate/20210127202613_remove_iteration_group_date_range_constraint.rb b/db/migrate/20210127202613_remove_iteration_group_date_range_constraint.rb new file mode 100644 index 00000000000..e6c5eb1b411 --- /dev/null +++ b/db/migrate/20210127202613_remove_iteration_group_date_range_constraint.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +class RemoveIterationGroupDateRangeConstraint < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + with_lock_retries do + execute <<~SQL + ALTER TABLE sprints + DROP CONSTRAINT IF EXISTS iteration_start_and_due_daterange_group_id_constraint + SQL + end + end + + def down + with_lock_retries do + execute <<~SQL + ALTER TABLE sprints + ADD CONSTRAINT iteration_start_and_due_daterange_group_id_constraint + EXCLUDE USING gist + ( group_id WITH =, + daterange(start_date, due_date, '[]') WITH && + ) + WHERE (group_id IS NOT NULL) + SQL + end + end +end |