From 96bd6479146d6e78280a9b72258b650b758870d7 Mon Sep 17 00:00:00 2001 From: Michael Becker <mbecker@gitlab.com> Date: Fri, 25 Oct 2024 21:11:59 -0700 Subject: [PATCH] Finalize `BackfillHasVulnerabilityResolution` migration We added this batched background migration in a previous MR. [^1] The [Batched Background Migration docs][0] 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 * I verified with chatops that the migration is complete.[^2] * The background migration is available in [`v17.5.0-ee`][1], which is a [required stop][2] [^1]: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/166110 [^2]:https://gitlab.com/gitlab-org/gitlab/-/issues/486530#note_2128952648 [0]:https://docs.gitlab.com/ee/development/database/batched_background_migrations.html#finalize-a-batched-background-migration [1]:https://gitlab.com/gitlab-org/security/gitlab/-/tree/v17.5.0-ee [2]:https://gitlab.com/gitlab-org/gitlab/-/blob/1842050872cc3a4062de067f9dbe6b86f1d9cd36/config/upgrade_path.yml#L77-79 --- related to: https://gitlab.com/gitlab-org/gitlab/-/issues/486530 resolves: https://gitlab.com/gitlab-org/gitlab/-/issues/496437 epic: https://gitlab.com/groups/gitlab-org/-/epics/15036 MR: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/170521 Changelog: changed --- .../backfill_has_vulnerability_resolution.yml | 2 +- ...e_backfill_has_vulnerability_resolution.rb | 23 +++++++++++++++++++ db/schema_migrations/20241025010332 | 1 + 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 db/post_migrate/20241025010332_finalize_backfill_has_vulnerability_resolution.rb create mode 100644 db/schema_migrations/20241025010332 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 dc37059029f51..d7ae69bab86e2 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: 20241025010332 diff --git a/db/post_migrate/20241025010332_finalize_backfill_has_vulnerability_resolution.rb b/db/post_migrate/20241025010332_finalize_backfill_has_vulnerability_resolution.rb new file mode 100644 index 0000000000000..99159fe2be7a7 --- /dev/null +++ b/db/post_migrate/20241025010332_finalize_backfill_has_vulnerability_resolution.rb @@ -0,0 +1,23 @@ +# 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 diff --git a/db/schema_migrations/20241025010332 b/db/schema_migrations/20241025010332 new file mode 100644 index 0000000000000..db615bcf311ce --- /dev/null +++ b/db/schema_migrations/20241025010332 @@ -0,0 +1 @@ +219459af48a3bdd8be64ba0cb8386dc6c2285b3106bda3ee5a83581cafa60d49 \ No newline at end of file -- GitLab