diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
commit | 3cccd102ba543e02725d247893729e5c73b38295 (patch) | |
tree | f36a04ec38517f5deaaacb5acc7d949688d1e187 /db/migrate/20220314184009_create_protected_environment_approval_rules.rb | |
parent | 205943281328046ef7b4528031b90fbda70c75ac (diff) |
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
Diffstat (limited to 'db/migrate/20220314184009_create_protected_environment_approval_rules.rb')
-rw-r--r-- | db/migrate/20220314184009_create_protected_environment_approval_rules.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/db/migrate/20220314184009_create_protected_environment_approval_rules.rb b/db/migrate/20220314184009_create_protected_environment_approval_rules.rb new file mode 100644 index 00000000000..f0db2c004ed --- /dev/null +++ b/db/migrate/20220314184009_create_protected_environment_approval_rules.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +class CreateProtectedEnvironmentApprovalRules < Gitlab::Database::Migration[1.0] + def up + create_table :protected_environment_approval_rules do |t| + t.references :protected_environment, + index: { name: :index_approval_rule_on_protected_environment_id }, + foreign_key: { to_table: :protected_environments, on_delete: :cascade }, + null: false + + t.bigint :user_id + t.bigint :group_id + t.timestamps_with_timezone null: false + t.integer :access_level, limit: 2 + t.integer :required_approvals, null: false, limit: 2 + + t.index :user_id + t.index :group_id + + t.check_constraint "((access_level IS NOT NULL) AND (group_id IS NULL) AND (user_id IS NULL)) OR " \ + "((user_id IS NOT NULL) AND (access_level IS NULL) AND (group_id IS NULL)) OR " \ + "((group_id IS NOT NULL) AND (user_id IS NULL) AND (access_level IS NULL))" + t.check_constraint "required_approvals > 0" + end + end + + def down + drop_table :protected_environment_approval_rules + end +end |