diff --git a/db/docs/batched_background_migrations/backfill_dast_scanner_profiles_builds_project_id.yml b/db/docs/batched_background_migrations/backfill_dast_scanner_profiles_builds_project_id.yml
index 80da079846a7f716f77e80db1ce7e5cfbbf8d88e..cbbb7a688a01a78cd42670cf821d6ee3c888137a 100644
--- a/db/docs/batched_background_migrations/backfill_dast_scanner_profiles_builds_project_id.yml
+++ b/db/docs/batched_background_migrations/backfill_dast_scanner_profiles_builds_project_id.yml
@@ -1,8 +1,9 @@
 ---
 migration_job_name: BackfillDastScannerProfilesBuildsProjectId
-description: Backfills sharding key `dast_scanner_profiles_builds.project_id` from `dast_scanner_profiles`.
+description: Backfills sharding key `dast_scanner_profiles_builds.project_id` from
+  `dast_scanner_profiles`.
 feature_category: dynamic_application_security_testing
 introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/167626
 milestone: '17.5'
 queued_migration_version: 20240930135301
-finalized_by: # version of the migration that finalized this BBM
+finalized_by: '20241027232438'
diff --git a/db/post_migrate/20241027232438_finalize_backfill_dast_scanner_profiles_builds_project_id.rb b/db/post_migrate/20241027232438_finalize_backfill_dast_scanner_profiles_builds_project_id.rb
new file mode 100644
index 0000000000000000000000000000000000000000..014c4e3ad3359287ff7fceb513f6df4093df8fd4
--- /dev/null
+++ b/db/post_migrate/20241027232438_finalize_backfill_dast_scanner_profiles_builds_project_id.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class FinalizeBackfillDastScannerProfilesBuildsProjectId < Gitlab::Database::Migration[2.2]
+  milestone '17.6'
+
+  disable_ddl_transaction!
+
+  restrict_gitlab_migration gitlab_schema: :gitlab_sec
+
+  def up
+    ensure_batched_background_migration_is_finished(
+      job_class_name: 'BackfillDastScannerProfilesBuildsProjectId',
+      table_name: :dast_scanner_profiles_builds,
+      column_name: :ci_build_id,
+      job_arguments: [:project_id, :dast_scanner_profiles, :project_id, :dast_scanner_profile_id],
+      finalize: true
+    )
+  end
+
+  def down; end
+end
diff --git a/db/schema_migrations/20241027232438 b/db/schema_migrations/20241027232438
new file mode 100644
index 0000000000000000000000000000000000000000..79a991180c588c545efa4b4f7ecc52bf8f158020
--- /dev/null
+++ b/db/schema_migrations/20241027232438
@@ -0,0 +1 @@
+bf583f1f7f53e25e861091a8afdf962d2fcc701f294620bbd9d4c3c9b8c12ae1
\ No newline at end of file