Skip to content

Create background migration to create compliance standards adherence

What does this MR do and why?

  1. Creates a background migration to create compliance standards adherence records for projects in a group.
  2. Existing rows of the compliance standards table are not updated.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

image

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Check the number of rows for project_compliance_standards_adherence table by running the following in rails console
Projects::ComplianceStandards::Adherence.count
  1. Queue background migration by running bundle exec rails db:migrate
  2. Verify that the batched background migration CreateComplianceStandardsAdherence is created by running the following in rails console.
Gitlab::Database::BackgroundMigration::BatchedMigration.find_by_job_class_name('CreateComplianceStandardsAdherence')
  1. Visit the background_migrations admin dashboard and verify that the background migration is completed successfully.
  2. Ensure that three rows inside project_compliance_standards_adherence table are created for every project that is in a group. We can run this (on GDK only since it's not a good query) to validate the same
group_projects_count = Project.for_group_and_its_subgroups(Group.all).count

compliance_standards_adherence_count = Projects::ComplianceStandards::Adherence.count

compliance_standards_adherence_count == 3 * group_projects_count # Ensure this is true
  1. Enable the following feature flags.
Feature.enable(:adherence_report_ui)
Feature.enable(:compliance_adherence_report)
  1. Visit the standards adherence dashboard and see that the dashboard has correct status for all the compliance checks.

MR acceptance checklist

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

Closes #413235 (closed)

Merge request reports