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:
Diffstat (limited to 'db/migrate/20220613112031_add_group_or_project_constraint_in_protected_branches.rb')
-rw-r--r--db/migrate/20220613112031_add_group_or_project_constraint_in_protected_branches.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/db/migrate/20220613112031_add_group_or_project_constraint_in_protected_branches.rb b/db/migrate/20220613112031_add_group_or_project_constraint_in_protected_branches.rb
new file mode 100644
index 00000000000..b7f20450480
--- /dev/null
+++ b/db/migrate/20220613112031_add_group_or_project_constraint_in_protected_branches.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddGroupOrProjectConstraintInProtectedBranches < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ CONSTRAINT_NAME = 'protected_branches_project_id_namespace_id_any_not_null'
+
+ def up
+ constraint = <<~CONSTRAINT
+ (project_id IS NULL) <> (namespace_id IS NULL)
+ CONSTRAINT
+ add_check_constraint :protected_branches, constraint, CONSTRAINT_NAME
+ end
+
+ def down
+ remove_check_constraint :protected_branches, CONSTRAINT_NAME
+ end
+end