Deployment Approvals data model
What does this MR do and why?
This is the first MR working towards an MVC for the new Deployment Approvals feature. See #343864 (closed) for context.
This MR introduces the deployment_approvals
feature flag. Rollout issue: #347342 (closed).
See !73340 (closed) to get an idea of how this data model will be used.
Migration output
db:migrate
:
== 20211119194024 AddRequiredApprovalCountToProtectedEnvironments: migrating ==
-- add_column(:protected_environments, :required_approval_count, :integer, {:default=>0, :null=>false})
-> 0.0027s
== 20211119194024 AddRequiredApprovalCountToProtectedEnvironments: migrated (0.0028s)
== 20211119195201 CreateDeploymentApprovals: migrating ========================
-- create_table(:deployment_approvals, {})
-> 0.0064s
== 20211119195201 CreateDeploymentApprovals: migrated (0.0064s) ===============
== 20211123181236 AddUserForeignKeyToDeploymentApprovals: migrating ===========
-- transaction_open?()
-> 0.0000s
-- foreign_keys(:deployment_approvals)
-> 0.0022s
-- transaction_open?()
-> 0.0000s
-- execute("ALTER TABLE deployment_approvals\nADD CONSTRAINT fk_0f58311058\nFOREIGN KEY (user_id)\nREFERENCES users (id)\nON DELETE CASCADE\nNOT VALID;\n")
-> 0.0015s
-- execute("ALTER TABLE deployment_approvals VALIDATE CONSTRAINT fk_0f58311058;")
-> 0.0089s
== 20211123181236 AddUserForeignKeyToDeploymentApprovals: migrated (0.0164s) ==
== 20211202041233 AddDeploymentForeignKeyToDeploymentApprovals: migrating =====
-- transaction_open?()
-> 0.0000s
-- foreign_keys(:deployment_approvals)
-> 0.0019s
-- transaction_open?()
-> 0.0000s
-- execute("ALTER TABLE deployment_approvals\nADD CONSTRAINT fk_2d060dfc73\nFOREIGN KEY (deployment_id)\nREFERENCES deployments (id)\nON DELETE CASCADE\nNOT VALID;\n")
-> 0.0016s
-- execute("ALTER TABLE deployment_approvals VALIDATE CONSTRAINT fk_2d060dfc73;")
-> 0.0162s
== 20211202041233 AddDeploymentForeignKeyToDeploymentApprovals: migrated (0.0232s)
== 20211207165508 AddProtectedEnvironmentsRequiredApprovalCountCheckConstraint: migrating
-- transaction_open?()
-> 0.0000s
-- current_schema()
-> 0.0002s
-- transaction_open?()
-> 0.0000s
-- execute("ALTER TABLE protected_environments\nADD CONSTRAINT protected_environments_required_approval_count_positive\nCHECK ( required_approval_count >= 0 )\nNOT VALID;\n")
-> 0.0007s
-- current_schema()
-> 0.0002s
-- execute("ALTER TABLE protected_environments VALIDATE CONSTRAINT protected_environments_required_approval_count_positive;")
-> 0.0016s
== 20211207165508 AddProtectedEnvironmentsRequiredApprovalCountCheckConstraint: migrated (0.0080s)
db:rollback
:
== 20211207165508 AddProtectedEnvironmentsRequiredApprovalCountCheckConstraint: reverting
-- transaction_open?()
-> 0.0000s
-- transaction_open?()
-> 0.0000s
-- execute("ALTER TABLE protected_environments\nDROP CONSTRAINT IF EXISTS protected_environments_required_approval_count_positive\n")
-> 0.0015s
== 20211207165508 AddProtectedEnvironmentsRequiredApprovalCountCheckConstraint: reverted (0.0169s)
== 20211202041233 AddDeploymentForeignKeyToDeploymentApprovals: reverting =====
-- transaction_open?()
-> 0.0000s
-- remove_foreign_key(:deployment_approvals, :deployments)
-> 0.0055s
== 20211202041233 AddDeploymentForeignKeyToDeploymentApprovals: reverted (0.0102s)
== 20211123181236 AddUserForeignKeyToDeploymentApprovals: reverting ===========
-- transaction_open?()
-> 0.0000s
-- remove_foreign_key(:deployment_approvals, :users)
-> 0.0039s
== 20211123181236 AddUserForeignKeyToDeploymentApprovals: reverted (0.0089s) ==
== 20211119195201 CreateDeploymentApprovals: reverting ========================
-- drop_table(:deployment_approvals, {})
-> 0.0035s
== 20211119195201 CreateDeploymentApprovals: reverted (0.0036s) ===============
== 20211119194024 AddRequiredApprovalCountToProtectedEnvironments: reverting ==
-- remove_column(:protected_environments, :required_approval_count, :integer, {:default=>0, :null=>false})
-> 0.0029s
== 20211119194024 AddRequiredApprovalCountToProtectedEnvironments: reverted (0.0030s)
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Alishan Ladhani