From 32b9635a277d73cd7352f4dc9ad2d4f39eb2b968 Mon Sep 17 00:00:00 2001
From: gdk <gdk@example.com>
Date: Sun, 3 Nov 2024 23:23:12 +0000
Subject: [PATCH] Finalize migration
 BackfillDastSiteProfileSecretVariablesProjectId

This migration was finished at `2024-06-06 21:55:06 UTC`, you can confirm
the status using our
[batched background migration chatops commands](https://docs.gitlab.com/ee/development/database/batched_background_migrations.html#monitor-the-progress-and-status-of-a-batched-background-migration).
  To confirm it is finished you can run:

  ```
/chatops run batched_background_migrations status 1000571
```

The last time this background migration was triggered was in [db/post_migrate/20240605192711_queue_backfill_dast_site_profile_secret_variables_project_id.rb](https://gitlab.com/gitlab-org/gitlab/-/blob/master/db/post_migrate/20240605192711_queue_backfill_dast_site_profile_secret_variables_project_id.rb)

  You can read more about the process for finalizing batched background migrations in
https://docs.gitlab.com/ee/development/database/batched_background_migrations.html .

  As part of our process we want to ensure all batched background migrations have had at least one
[required stop](https://docs.gitlab.com/ee/development/database/required_stops.html)
to process the migration. Therefore we can finalize any batched background migration that was added before the
last required stop.

This change was generated by
[gitlab-housekeeper](https://gitlab.com/gitlab-org/gitlab/-/tree/master/gems/gitlab-housekeeper)
using the Keeps::OverdueFinalizeBackgroundMigration keep.

To provide feedback on your experience with `gitlab-housekeeper` please create an issue with the
label ~"GitLab Housekeeper" and consider pinging the author of this keep.

Changelog: other
---
 ...te_profile_secret_variables_project_id.yml |  5 +++--
 ...ite_profile_secret_variables_project_id.rb | 21 +++++++++++++++++++
 db/schema_migrations/20241103232302           |  1 +
 3 files changed, 25 insertions(+), 2 deletions(-)
 create mode 100644 db/post_migrate/20241103232302_finalize_backfill_dast_site_profile_secret_variables_project_id.rb
 create mode 100644 db/schema_migrations/20241103232302

diff --git a/db/docs/batched_background_migrations/backfill_dast_site_profile_secret_variables_project_id.yml b/db/docs/batched_background_migrations/backfill_dast_site_profile_secret_variables_project_id.yml
index dabf679da22e..5eece976e8d1 100644
--- a/db/docs/batched_background_migrations/backfill_dast_site_profile_secret_variables_project_id.yml
+++ b/db/docs/batched_background_migrations/backfill_dast_site_profile_secret_variables_project_id.yml
@@ -1,8 +1,9 @@
 ---
 migration_job_name: BackfillDastSiteProfileSecretVariablesProjectId
-description: Backfills sharding key `dast_site_profile_secret_variables.project_id` from `dast_site_profiles`.
+description: Backfills sharding key `dast_site_profile_secret_variables.project_id`
+  from `dast_site_profiles`.
 feature_category: dynamic_application_security_testing
 introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/155491
 milestone: '17.1'
 queued_migration_version: 20240605192711
-finalized_by: # version of the migration that finalized this BBM
+finalized_by: '20241103232302'
diff --git a/db/post_migrate/20241103232302_finalize_backfill_dast_site_profile_secret_variables_project_id.rb b/db/post_migrate/20241103232302_finalize_backfill_dast_site_profile_secret_variables_project_id.rb
new file mode 100644
index 000000000000..3069dc11a315
--- /dev/null
+++ b/db/post_migrate/20241103232302_finalize_backfill_dast_site_profile_secret_variables_project_id.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class FinalizeBackfillDastSiteProfileSecretVariablesProjectId < Gitlab::Database::Migration[2.2]
+  milestone '17.6'
+
+  disable_ddl_transaction!
+
+  restrict_gitlab_migration gitlab_schema: :gitlab_main_cell
+
+  def up
+    ensure_batched_background_migration_is_finished(
+      job_class_name: 'BackfillDastSiteProfileSecretVariablesProjectId',
+      table_name: :dast_site_profile_secret_variables,
+      column_name: :id,
+      job_arguments: [:project_id, :dast_site_profiles, :project_id, :dast_site_profile_id],
+      finalize: true
+    )
+  end
+
+  def down; end
+end
diff --git a/db/schema_migrations/20241103232302 b/db/schema_migrations/20241103232302
new file mode 100644
index 000000000000..162bbc8f81fe
--- /dev/null
+++ b/db/schema_migrations/20241103232302
@@ -0,0 +1 @@
+19ad7e18e150444fa63771e3304172eb487488075f0cfa427c6ccf1b4c332490
\ No newline at end of file
-- 
GitLab