Remove NOT NULL on policy_id for scan_result_policy_violations
What does this MR do and why?
This change updates scan_result_policy_violations
table to remove the NOT NULL
constraint on scan_result_policy_id
as it will be replaced by approval_policy_rule_id
as a part of Use database read model for merge request appr... (&9971)
Migration Output
Migrate Up
main: == [advisory_lock_connection] object_id: 128500, pg_backend_pid: 15855
main: == 20240704123140 RemoveScanResultPolicyViolationsPolicyIdNotNull: migrating ==
main: -- execute("ALTER TABLE scan_result_policy_violations ALTER COLUMN scan_result_policy_id DROP NOT NULL")
main: -> 0.0022s
main: == 20240704123140 RemoveScanResultPolicyViolationsPolicyIdNotNull: migrated (0.0092s)
main: == [advisory_lock_connection] object_id: 128500, pg_backend_pid: 15855
main: == [advisory_lock_connection] object_id: 133120, pg_backend_pid: 36853
main: == 20240709115642 AddApprovalPolicyIdConstraintToScanResultPolicyViolations: migrating
main: -- transaction_open?(nil)
main: -> 0.0000s
main: -- transaction_open?(nil)
main: -> 0.0000s
main: -- execute("ALTER TABLE scan_result_policy_violations\nADD CONSTRAINT chk_policy_violations_rule_id_or_policy_id_not_null\nCHECK ( approval_policy_rule_id IS NOT NULL OR scan_result_policy_id IS NOT NULL )\nNOT VALID;\n")
main: -> 0.0020s
main: -- execute("SET statement_timeout TO 0")
main: -> 0.0010s
main: -- execute("ALTER TABLE scan_result_policy_violations VALIDATE CONSTRAINT chk_policy_violations_rule_id_or_policy_id_not_null;")
main: -> 0.0045s
main: -- execute("RESET statement_timeout")
main: -> 0.0016s
main: == 20240709115642 AddApprovalPolicyIdConstraintToScanResultPolicyViolations: migrated (0.1002s)
main: == [advisory_lock_connection] object_id: 133120, pg_backend_pid: 36853
Migrate Down
main: == [advisory_lock_connection] object_id: 128500, pg_backend_pid: 15386
main: == 20240704123140 RemoveScanResultPolicyViolationsPolicyIdNotNull: reverting ==
main: -- execute("ALTER TABLE scan_result_policy_violations ALTER COLUMN scan_result_policy_id SET NOT NULL")
main: -> 0.0025s
main: == 20240704123140 RemoveScanResultPolicyViolationsPolicyIdNotNull: reverted (0.0073s)
main: == [advisory_lock_connection] object_id: 128500, pg_backend_pid: 15386
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Addresses #464034 (closed)
Edited by Sashi Kumar Kumaresan