Add supported tables for group approval rules
What does this MR do?
This MR creates all tables required to support the management of group-level MR approval rules.
Since the DB changes are getting rather big, I will move the API to a separate MR to make reviewing a bit easier.
- High-level design #293957
- Implementation issue #325646 (closed)
🐘 Database
Migration/Rollback Log
Migrate
== 20210329124955 AddApprovalGroupRules: migrating ============================
-- create_table(:approval_group_rules, {:if_not_exists=>true})
-> 0.0149s
-- transaction_open?()
-> 0.0000s
-- current_schema()
-> 0.0003s
-- execute("ALTER TABLE approval_group_rules\nADD CONSTRAINT check_25d42add43\nCHECK ( char_length(name) <= 255 )\nNOT VALID;\n")
-> 0.0012s
-- current_schema()
-> 0.0003s
-- execute("SET statement_timeout TO 0")
-> 0.0010s
-- execute("ALTER TABLE approval_group_rules VALIDATE CONSTRAINT check_25d42add43;")
-> 0.0014s
-- execute("RESET ALL")
-> 0.0017s
== 20210329124955 AddApprovalGroupRules: migrated (0.0569s) ===================
== 20210330064326 AddApprovalGroupsRulesGroups: migrating =====================
-- create_table(:approval_group_rules_groups)
-> 0.0070s
-- add_index(:approval_group_rules_groups, :approval_group_rule_id)
-> 0.0054s
-- add_index(:approval_group_rules_groups, :group_id)
-> 0.0045s
== 20210330064326 AddApprovalGroupsRulesGroups: migrated (0.0182s) ============
== 20210330064433 AddApprovalGroupsRulesUsers: migrating ======================
-- create_table(:approval_group_rules_users)
-> 0.0077s
-- add_index(:approval_group_rules_users, :approval_group_rule_id)
-> 0.0039s
-- add_index(:approval_group_rules_users, :user_id)
-> 0.0049s
== 20210330064433 AddApprovalGroupsRulesUsers: migrated (0.0167s) =============
== 20210331051716 AddFkToApprovalRuleOnApprovalGroupRulesUsers: migrating =====
-- transaction_open?()
-> 0.0000s
-- foreign_keys(:approval_group_rules_users)
-> 0.0036s
-- execute("ALTER TABLE approval_group_rules_users\nADD CONSTRAINT fk_9a4b673183\nFOREIGN KEY (approval_group_rule_id)\nREFERENCES approval_group_rules (id)\nON DELETE CASCADE\nNOT VALID;\n")
-> 0.0024s
-- execute("ALTER TABLE approval_group_rules_users VALIDATE CONSTRAINT fk_9a4b673183;")
-> 0.0025s
== 20210331051716 AddFkToApprovalRuleOnApprovalGroupRulesUsers: migrated (0.0184s)
== 20210331051807 AddFkToUserOnApprovalGroupRulesUsers: migrating =============
-- transaction_open?()
-> 0.0000s
-- foreign_keys(:approval_group_rules_users)
-> 0.0022s
-- execute("ALTER TABLE approval_group_rules_users\nADD CONSTRAINT fk_888a0df3b7\nFOREIGN KEY (user_id)\nREFERENCES users (id)\nON DELETE CASCADE\nNOT VALID;\n")
-> 0.0034s
-- execute("ALTER TABLE approval_group_rules_users VALIDATE CONSTRAINT fk_888a0df3b7;")
-> 0.0033s
== 20210331051807 AddFkToUserOnApprovalGroupRulesUsers: migrated (0.0217s) ====
== 20210331051844 AddFkToApprovalRuleOnApprovalGroupRulesGroups: migrating ====
-- transaction_open?()
-> 0.0000s
-- foreign_keys(:approval_group_rules_groups)
-> 0.0022s
-- execute("ALTER TABLE approval_group_rules_groups\nADD CONSTRAINT fk_efff219a48\nFOREIGN KEY (approval_group_rule_id)\nREFERENCES approval_group_rules (id)\nON DELETE CASCADE\nNOT VALID;\n")
-> 0.0023s
-- execute("ALTER TABLE approval_group_rules_groups VALIDATE CONSTRAINT fk_efff219a48;")
-> 0.0016s
== 20210331051844 AddFkToApprovalRuleOnApprovalGroupRulesGroups: migrated (0.0179s)
== 20210331052026 AddFkToGroupOnApprovalGroupRulesGroups: migrating ===========
-- transaction_open?()
-> 0.0000s
-- foreign_keys(:approval_group_rules_groups)
-> 0.0030s
-- execute("ALTER TABLE approval_group_rules_groups\nADD CONSTRAINT fk_50edc8134e\nFOREIGN KEY (group_id)\nREFERENCES namespaces (id)\nON DELETE CASCADE\nNOT VALID;\n")
-> 0.0024s
-- execute("ALTER TABLE approval_group_rules_groups VALIDATE CONSTRAINT fk_50edc8134e;")
-> 0.0035s
== 20210331052026 AddFkToGroupOnApprovalGroupRulesGroups: migrated (0.0188s) ==
Rollback
== 20210331052026 AddFkToGroupOnApprovalGroupRulesGroups: reverting ===========
-- remove_foreign_key(:approval_group_rules_groups, {:column=>:group_id})
-> 0.0040s
== 20210331052026 AddFkToGroupOnApprovalGroupRulesGroups: reverted (0.0101s) ==
== 20210331051844 AddFkToApprovalRuleOnApprovalGroupRulesGroups: reverting ====
-- remove_foreign_key(:approval_group_rules_groups, {:column=>:approval_group_rule_id})
-> 0.0042s
== 20210331051844 AddFkToApprovalRuleOnApprovalGroupRulesGroups: reverted (0.0103s)
== 20210331051807 AddFkToUserOnApprovalGroupRulesUsers: reverting =============
-- remove_foreign_key(:approval_group_rules_users, {:column=>:user_id})
-> 0.0043s
== 20210331051807 AddFkToUserOnApprovalGroupRulesUsers: reverted (0.0107s) ====
== 20210331051716 AddFkToApprovalRuleOnApprovalGroupRulesUsers: reverting =====
-- remove_foreign_key(:approval_group_rules_users, {:column=>:approval_group_rule_id})
-> 0.0043s
== 20210331051716 AddFkToApprovalRuleOnApprovalGroupRulesUsers: reverted (0.0106s)
== 20210330064433 AddApprovalGroupsRulesUsers: reverting ======================
-- drop_table(:approval_group_rules_users)
-> 0.0042s
== 20210330064433 AddApprovalGroupsRulesUsers: reverted (0.0044s) =============
== 20210330064326 AddApprovalGroupsRulesGroups: reverting =====================
-- drop_table(:approval_group_rules_groups)
-> 0.0042s
== 20210330064326 AddApprovalGroupsRulesGroups: reverted (0.0043s) ============
== 20210329124955 AddApprovalGroupRules: reverting ============================
-- drop_table(:approval_group_rules)
-> 0.0022s
== 20210329124955 AddApprovalGroupRules: reverted (0.0101s) ===================
Does this MR meet the acceptance criteria?
Conformity
-
📋 Does this MR need a changelog?-
I have included a changelog entry. -
I have not included a changelog entry because _____.
-
- [-] Documentation (if required)
-
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. - [-] Tested in all supported browsers
- [-] Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
- [-] Label as security and @ mention
@gitlab-com/gl-security/appsec
- [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
- [-] Security reports checked/validated by a reviewer from the AppSec team
Edited by Tan Le