diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 14:33:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 14:33:21 +0300 |
commit | 7021455bd1ed7b125c55eb1b33c5a01f2bc55ee0 (patch) | |
tree | 5bdc2229f5198d516781f8d24eace62fc7e589e9 /db/migrate/20220613112031_add_group_or_project_constraint_in_protected_branches.rb | |
parent | 185b095e93520f96e9cfc31d9c3e69b498cdab7c (diff) |
Add latest changes from gitlab-org/gitlab@15-6-stable-eev15.6.0-rc42
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.rb | 18 |
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 |