Skip to content

Create BranchRule model

Joe Woodward requested to merge feat/branch-rule-model into master

What does this MR do and why?

Creates the BranchRule model in preparation for BranchRuleMVC

Describe in detail what your merge request does and why.

This is the first MR to create the new architecture for BranchRuleMVC. In this MR I have created the BranchRule model and configured a the associations. I have also updated the db/docs to include the model and added the model to all_models.yml

Migration Output

UP

main: == 20220727103547 CreateBranchRules: migrating ================================
main: -- create_table(:branch_rules, {})
main: -- quote_column_name(:name)
main:    -> 0.0000s
main:    -> 0.0105s
main: == 20220727103547 CreateBranchRules: migrated (0.0124s) =======================

main: == 20220727105500 AddProjectFkToBranchRules: migrating ========================
main: -- transaction_open?()
main:    -> 0.0000s
main: -- foreign_keys(:branch_rules)
main:    -> 0.0036s
main: -- transaction_open?()
main:    -> 0.0000s
main: -- execute("ALTER TABLE branch_rules\nADD CONSTRAINT fk_56de1c4dcc\nFOREIGN KEY (project_id)\nREFERENCES projects (id)\nON DELETE CASCADE\nNOT VALID;\n")
main:    -> 0.0014s
main: -- execute("SET statement_timeout TO 0")
main:    -> 0.0003s
main: -- execute("ALTER TABLE branch_rules VALIDATE CONSTRAINT fk_56de1c4dcc;")
main:    -> 0.0029s
main: -- execute("RESET statement_timeout")
main:    -> 0.0003s
main: == 20220727105500 AddProjectFkToBranchRules: migrated (0.0146s) ===============

main: == 20220727105536 AddProtectedBranchFkToBranchRules: migrating ================
main: -- transaction_open?()
main:    -> 0.0000s
main: -- foreign_keys(:branch_rules)
main:    -> 0.0018s
main: -- transaction_open?()
main:    -> 0.0000s
main: -- execute("ALTER TABLE branch_rules\nADD CONSTRAINT fk_2b7d491832\nFOREIGN KEY (legacy_protected_branch_id)\nREFERENCES protected_branches (id)\nON DELETE CASCADE\nNOT VALID;\n")
main:    -> 0.0008s
main: -- execute("ALTER TABLE branch_rules VALIDATE CONSTRAINT fk_2b7d491832;")
main:    -> 0.0007s
main: == 20220727105536 AddProtectedBranchFkToBranchRules: migrated (0.0054s) =======

ci: == 20220727103547 CreateBranchRules: migrating ================================
ci: -- create_table(:branch_rules, {})
ci: -- quote_column_name(:name)
ci:    -> 0.0000s
ci:    -> 0.0071s
ci: == 20220727103547 CreateBranchRules: migrated (0.0072s) =======================

ci: == 20220727105500 AddProjectFkToBranchRules: migrating ========================
ci: -- transaction_open?()
ci:    -> 0.0000s
ci: -- foreign_keys(:branch_rules)
ci:    -> 0.0022s
ci: -- transaction_open?()
ci:    -> 0.0000s
ci: -- execute("ALTER TABLE branch_rules\nADD CONSTRAINT fk_56de1c4dcc\nFOREIGN KEY (project_id)\nREFERENCES projects (id)\nON DELETE CASCADE\nNOT VALID;\n")
ci:    -> 0.0016s
ci: -- execute("SET statement_timeout TO 0")
ci:    -> 0.0002s
ci: -- execute("ALTER TABLE branch_rules VALIDATE CONSTRAINT fk_56de1c4dcc;")
ci:    -> 0.0034s
ci: -- execute("RESET statement_timeout")
ci:    -> 0.0006s
ci: == 20220727105500 AddProjectFkToBranchRules: migrated (0.0098s) ===============

ci: == 20220727105536 AddProtectedBranchFkToBranchRules: migrating ================
ci: -- transaction_open?()
ci:    -> 0.0000s
ci: -- foreign_keys(:branch_rules)
ci:    -> 0.0018s
ci: -- transaction_open?()
ci:    -> 0.0000s
ci: -- execute("ALTER TABLE branch_rules\nADD CONSTRAINT fk_2b7d491832\nFOREIGN KEY (legacy_protected_branch_id)\nREFERENCES protected_branches (id)\nON DELETE CASCADE\nNOT VALID;\n")
ci:    -> 0.0009s
ci: -- execute("ALTER TABLE branch_rules VALIDATE CONSTRAINT fk_2b7d491832;")
ci:    -> 0.0008s
ci: == 20220727105536 AddProtectedBranchFkToBranchRules: migrated (0.0053s) =======

Down

main: == 20220727105536 AddProtectedBranchFkToBranchRules: reverting ================
main: -- transaction_open?()
main:    -> 0.0000s
main: -- remove_foreign_key(:branch_rules, {:column=>:legacy_protected_branch_id})
main:    -> 0.0050s
main: == 20220727105536 AddProtectedBranchFkToBranchRules: reverted (0.0140s) =======

main: == 20220727105500 AddProjectFkToBranchRules: reverting ========================
main: -- transaction_open?()
main:    -> 0.0000s
main: -- remove_foreign_key(:branch_rules, {:column=>:project_id})
main:    -> 0.0052s
main: == 20220727105500 AddProjectFkToBranchRules: reverted (0.0134s) ===============

main: == 20220727103547 CreateBranchRules: reverting ================================
main: -- drop_table(:branch_rules, {})
main:    -> 0.0031s
main: == 20220727103547 CreateBranchRules: reverted (0.0049s) =======================

ci: == 20220727105536 AddProtectedBranchFkToBranchRules: reverting ================
ci: -- transaction_open?()
ci:    -> 0.0000s
ci: -- remove_foreign_key(:branch_rules, {:column=>:legacy_protected_branch_id})
ci:    -> 0.0048s
ci: == 20220727105536 AddProtectedBranchFkToBranchRules: reverted (0.0133s) =======

ci: == 20220727105500 AddProjectFkToBranchRules: reverting ========================
ci: -- transaction_open?()
ci:    -> 0.0000s
ci: -- remove_foreign_key(:branch_rules, {:column=>:project_id})
ci:    -> 0.0052s
ci: == 20220727105500 AddProjectFkToBranchRules: reverted (0.0146s) ===============

ci: == 20220727103547 CreateBranchRules: reverting ================================
ci: -- drop_table(:branch_rules, {})
ci:    -> 0.0027s
ci: == 20220727103547 CreateBranchRules: reverted (0.0044s) =======================

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Joe Woodward

Merge request reports