Welcome to mirror list, hosted at ThFree Co, Russian Federation.

20210127202613_remove_iteration_group_date_range_constraint.rb « migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e6c5eb1b41153302f6f84f92c64bb0085c6d3187 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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