Finalize `BackfillHasVulnerabilityResolution` migration

Context

We need to be able to filter vulnerabilities on whether they have the "Resolve with Duo" button enabled.

To support this feature, we:

  • Added a new column to support this filter 1
  • Created a batched background migration to backfill the new column2

This issue

The Batched Background Migration docs say to finalize a migration when two conditions are met:

  1. The batched background migration is completed on GitLab.com
  2. The batched background migration was added in or before the last required stop

Verify complete on GitLab.com

verified with chatops and details here

/chatops run batched_background_migrations status 1000706 --production

Verify required stop

The migration is available in v17.5.0-ee

/chatops run release check https://gitlab.com/gitlab-org/gitlab/-/merge_requests/166110 17.5

17.5 is a required stop, so we can finalize in 17.6

Implementation Plan

  1. generate migration
bundle exec rails g post_deployment_migration:post_deployment_migration FinalizeBackfillHasVulnerabilityResolution
  1. Fill in the migration to finalize the backfill:
 diff --git a/db/docs/batched_background_migrations/backfill_has_vulnerability_resolution.yml b/db/docs/batched_background_migrations/backfill_has_vulnerability_resolution.yml
 index dc37059029f5..ef744cf51cc4 100644
 --- a/db/docs/batched_background_migrations/backfill_has_vulnerability_resolution.yml
 +++ b/db/docs/batched_background_migrations/backfill_has_vulnerability_resolution.yml
 @@ -10,4 +10,4 @@ feature_category: vulnerability_management
  introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/166110
  milestone: '17.5'
  queued_migration_version: 20240912184158
 -finalized_by: # version of the migration that finalized this BBM
 +finalized_by: 12345 # version of the migration that finalized this BBM
 diff --git a/db/post_migrate/20240930103114_finalize_backfill_has_vulnerability_resolution.rb b/db/post_migrate/20240930103114_finalize_backfill_has_vulnerability_resolution.rb
 new file mode 100644
 index 000000000000..59317199f521
 --- /dev/null
 +++ b/db/post_migrate/20240930103114_finalize_backfill_has_vulnerability_resolution.rb
 @@ -0,0 +1,22 @@
 +# frozen_string_literal: true
 +
 +class FinalizeBackfillHasVulnerabilityResolution < Gitlab::Database::Migration[2.2]
 +  MIGRATION = 'BackfillHasVulnerabilityResolution'
 +  disable_ddl_transaction!
 +  restrict_gitlab_migration gitlab_schema: :gitlab_main
 +  milestone '17.6'
 +
 +  def up
 +    ensure_batched_background_migration_is_finished(
 +      job_class_name: MIGRATION,
 +      table_name: :vulnerability_reads,
 +      column_name: :id,
 +      job_arguments: [],
 +      finalize: true
 +    )
 +  end
 +
 +  def down
 +    # no-op
 +  end
 +end
  1. Add `has_vulnerability_resolution` column to `v... (!165548 - merged)

  2. Backfill for `vulnerability_reads.has_vulnerabi... (!166110 - merged)

Edited by Michael Becker