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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-08-20 21:42:06 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-08-20 21:42:06 +0300
commit6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch)
tree78be5963ec075d80116a932011d695dd33910b4e /db/migrate/20200515153633_iteration_date_range_constraint.rb
parent1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff)
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'db/migrate/20200515153633_iteration_date_range_constraint.rb')
-rw-r--r--db/migrate/20200515153633_iteration_date_range_constraint.rb39
1 files changed, 39 insertions, 0 deletions
diff --git a/db/migrate/20200515153633_iteration_date_range_constraint.rb b/db/migrate/20200515153633_iteration_date_range_constraint.rb
new file mode 100644
index 00000000000..ab197ff8ae7
--- /dev/null
+++ b/db/migrate/20200515153633_iteration_date_range_constraint.rb
@@ -0,0 +1,39 @@
+# frozen_string_literal: true
+
+class IterationDateRangeConstraint < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ def up
+ execute <<~SQL
+ ALTER TABLE sprints
+ ADD CONSTRAINT iteration_start_and_due_daterange_project_id_constraint
+ EXCLUDE USING gist
+ ( project_id WITH =,
+ daterange(start_date, due_date, '[]') WITH &&
+ )
+ WHERE (project_id IS NOT NULL)
+ SQL
+
+ 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
+
+ def down
+ execute <<~SQL
+ ALTER TABLE sprints
+ DROP CONSTRAINT IF EXISTS iteration_start_and_due_daterange_project_id_constraint
+ SQL
+
+ execute <<~SQL
+ ALTER TABLE sprints
+ DROP CONSTRAINT IF EXISTS iteration_start_and_due_daterange_group_id_constraint
+ SQL
+ end
+end