Skip to content

Adding compliance requirement controls table and model

Hitesh Raghuvanshi requested to merge 508483-compliance-controls-table-1 into master

What does this MR do and why?

As per https://handbook.gitlab.com/handbook/engineering/architecture/design-documents/compliance-adherence-reporting/decisions/006_storing_controls_in_a_separate_table/, adding table for compliance_requirements_controls for storing controls for compliance requirements.

References

Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.

Database

Migration 1: Creation of table


### up

bundle exec rake db:migrate:up:main VERSION=20241216070908
main: == [advisory_lock_connection] object_id: 130580, pg_backend_pid: 61963
main: == 20241216070908 CreateComplianceRequirementsControls: migrating =============
main: -- create_table(:compliance_requirements_controls)
main: -- quote_column_name(:external_url)
main:    -> 0.0000s
main: -- quote_column_name(:expression)
main:    -> 0.0000s
main:    -> 0.0237s
main: == 20241216070908 CreateComplianceRequirementsControls: migrated (0.0612s) ====

main: == [advisory_lock_connection] object_id: 130580, pg_backend_pid: 61963

### down

bundle exec rake db:migrate:down:main VERSION=20241216070908              
main: == [advisory_lock_connection] object_id: 130580, pg_backend_pid: 40764
main: == 20241216070908 CreateComplianceRequirementsControls: reverting =============
main: -- drop_table(:compliance_requirements_controls)
main:    -> 0.0049s
main: == 20241216070908 CreateComplianceRequirementsControls: reverted (0.0144s) ====

main: == [advisory_lock_connection] object_id: 130580, pg_backend_pid: 40764

Migration 2: Adding namespace_id as foreign key


### up

bundle exec rake db:migrate:up:main VERSION=20241216072130
main: == [advisory_lock_connection] object_id: 130580, pg_backend_pid: 79002
main: == 20241216072130 AddForeignKeyToComplianceControlsNamespaceId: migrating =====
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- execute("ALTER TABLE compliance_requirements_controls ADD CONSTRAINT fk_fbad5ced4f FOREIGN KEY (namespace_id) REFERENCES namespaces (id) ON DELETE CASCADE NOT VALID;")
main:    -> 0.0114s
main: -- execute("SET statement_timeout TO 0")
main:    -> 0.0009s
main: -- execute("ALTER TABLE compliance_requirements_controls VALIDATE CONSTRAINT fk_fbad5ced4f;")
main:    -> 0.0137s
main: -- execute("RESET statement_timeout")
main:    -> 0.0043s
main: == 20241216072130 AddForeignKeyToComplianceControlsNamespaceId: migrated (0.1476s) 

main: == [advisory_lock_connection] object_id: 130580, pg_backend_pid: 79002


### down

bundle exec rake db:migrate:down:main VERSION=20241216072130              
main: == [advisory_lock_connection] object_id: 130600, pg_backend_pid: 57212
main: == 20241216072130 AddForeignKeyToComplianceControlsNamespaceId: reverting =====
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- remove_foreign_key(:compliance_requirements_controls, {:column=>:namespace_id})
main:    -> 0.0297s
main: == 20241216072130 AddForeignKeyToComplianceControlsNamespaceId: reverted (0.0505s) 

main: == [advisory_lock_connection] object_id: 130600, pg_backend_pid: 57212

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.

Related to #508483 (closed)

Edited by Hitesh Raghuvanshi

Merge request reports

Loading