From f4c506f3a2dfb67fc8c07662cb3bcd3fc4a69e2d Mon Sep 17 00:00:00 2001
From: gdk <gdk@example.com>
Date: Thu, 27 Feb 2025 23:19:44 +0000
Subject: [PATCH] Finalize migration BackfillMlCandidateMetricsProjectId

This migration was finished at `2024-09-16 21:26:11 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 1000666
```

The last time this background migration was triggered was in [db/post_migrate/20240830093237_queue_backfill_ml_candidate_metrics_project_id.rb](https://gitlab.com/gitlab-org/gitlab/-/blob/master/db/post_migrate/20240830093237_queue_backfill_ml_candidate_metrics_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
---
 ...ckfill_ml_candidate_metrics_project_id.yml |  2 +-
 ...ackfill_ml_candidate_metrics_project_id.rb | 21 +++++++++++++++++++
 db/schema_migrations/20250227231923           |  1 +
 3 files changed, 23 insertions(+), 1 deletion(-)
 create mode 100644 db/post_migrate/20250227231923_finalize_hk_backfill_ml_candidate_metrics_project_id.rb
 create mode 100644 db/schema_migrations/20250227231923

diff --git a/db/docs/batched_background_migrations/backfill_ml_candidate_metrics_project_id.yml b/db/docs/batched_background_migrations/backfill_ml_candidate_metrics_project_id.yml
index 3fc00fc48f2c..092848928111 100644
--- a/db/docs/batched_background_migrations/backfill_ml_candidate_metrics_project_id.yml
+++ b/db/docs/batched_background_migrations/backfill_ml_candidate_metrics_project_id.yml
@@ -6,4 +6,4 @@ introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/164465
 milestone: '17.4'
 queued_migration_version: 20240830093237
 finalize_after: '2024-09-22'
-finalized_by: # version of the migration that finalized this BBM
+finalized_by: '20250227231923'
diff --git a/db/post_migrate/20250227231923_finalize_hk_backfill_ml_candidate_metrics_project_id.rb b/db/post_migrate/20250227231923_finalize_hk_backfill_ml_candidate_metrics_project_id.rb
new file mode 100644
index 000000000000..c63fce6dc820
--- /dev/null
+++ b/db/post_migrate/20250227231923_finalize_hk_backfill_ml_candidate_metrics_project_id.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class FinalizeHkBackfillMlCandidateMetricsProjectId < Gitlab::Database::Migration[2.2]
+  milestone '17.10'
+
+  disable_ddl_transaction!
+
+  restrict_gitlab_migration gitlab_schema: :gitlab_main_cell
+
+  def up
+    ensure_batched_background_migration_is_finished(
+      job_class_name: 'BackfillMlCandidateMetricsProjectId',
+      table_name: :ml_candidate_metrics,
+      column_name: :id,
+      job_arguments: [:project_id, :ml_candidates, :project_id, :candidate_id],
+      finalize: true
+    )
+  end
+
+  def down; end
+end
diff --git a/db/schema_migrations/20250227231923 b/db/schema_migrations/20250227231923
new file mode 100644
index 000000000000..65419842c256
--- /dev/null
+++ b/db/schema_migrations/20250227231923
@@ -0,0 +1 @@
+c46925afb8d17e17b664b13ca621d794760fca62e6bafcaa005f45a0fc12ca69
\ No newline at end of file
-- 
GitLab