From 71bfc49c0f36c277d7a4bf833e14b468eba75f58 Mon Sep 17 00:00:00 2001
From: Mario Celi <mcelicalderon@gitlab.com>
Date: Wed, 30 Oct 2024 12:06:05 -0500
Subject: [PATCH] Finalize migration BackfillIssuesCorrectWorkItemTypeId

Migration finished running in .com
so we can finalize it. Migration was scheduled
in 17.5 so it's safe to finalize in 17.6.

Changelo: other
---
 ...kfill_issues_correct_work_item_type_id.yml |  2 +-
 ...ckfill_issues_correct_work_item_type_id.rb | 24 +++++++++++++++++++
 db/schema_migrations/20241030165330           |  1 +
 ...l_issues_correct_work_item_type_id_spec.rb |  4 +++-
 4 files changed, 29 insertions(+), 2 deletions(-)
 create mode 100644 db/post_migrate/20241030165330_finalize_backfill_issues_correct_work_item_type_id.rb
 create mode 100644 db/schema_migrations/20241030165330

diff --git a/db/docs/batched_background_migrations/backfill_issues_correct_work_item_type_id.yml b/db/docs/batched_background_migrations/backfill_issues_correct_work_item_type_id.yml
index 734f0ec90eb1d..5b8268a62454d 100644
--- a/db/docs/batched_background_migrations/backfill_issues_correct_work_item_type_id.yml
+++ b/db/docs/batched_background_migrations/backfill_issues_correct_work_item_type_id.yml
@@ -5,4 +5,4 @@ feature_category: team_planning
 introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/167972
 milestone: '17.5'
 queued_migration_version: 20241002185804
-finalized_by: # version of the migration that finalized this BBM
+finalized_by: 20241030165330
diff --git a/db/post_migrate/20241030165330_finalize_backfill_issues_correct_work_item_type_id.rb b/db/post_migrate/20241030165330_finalize_backfill_issues_correct_work_item_type_id.rb
new file mode 100644
index 0000000000000..7762ee4734264
--- /dev/null
+++ b/db/post_migrate/20241030165330_finalize_backfill_issues_correct_work_item_type_id.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+class FinalizeBackfillIssuesCorrectWorkItemTypeId < Gitlab::Database::Migration[2.2]
+  disable_ddl_transaction!
+  restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+  milestone '17.6'
+
+  MIGRATION = "BackfillIssuesCorrectWorkItemTypeId"
+
+  def up
+    ensure_batched_background_migration_is_finished(
+      job_class_name: MIGRATION,
+      table_name: :issues,
+      column_name: :id,
+      job_arguments: [],
+      finalize: true
+    )
+  end
+
+  def down
+    # no-op
+  end
+end
diff --git a/db/schema_migrations/20241030165330 b/db/schema_migrations/20241030165330
new file mode 100644
index 0000000000000..be978d59a0137
--- /dev/null
+++ b/db/schema_migrations/20241030165330
@@ -0,0 +1 @@
+cc3ef05bcf103ea2e3a69a450eb71be8680fd6d4aa9d6538276667003eadd24b
\ No newline at end of file
diff --git a/spec/lib/gitlab/background_migration/backfill_issues_correct_work_item_type_id_spec.rb b/spec/lib/gitlab/background_migration/backfill_issues_correct_work_item_type_id_spec.rb
index 586bb3ae4091c..fc9e300350eae 100644
--- a/spec/lib/gitlab/background_migration/backfill_issues_correct_work_item_type_id_spec.rb
+++ b/spec/lib/gitlab/background_migration/backfill_issues_correct_work_item_type_id_spec.rb
@@ -2,7 +2,9 @@
 
 require 'spec_helper'
 
-RSpec.describe Gitlab::BackgroundMigration::BackfillIssuesCorrectWorkItemTypeId, feature_category: :team_planning do
+RSpec.describe Gitlab::BackgroundMigration::BackfillIssuesCorrectWorkItemTypeId,
+  feature_category: :team_planning,
+  schema: 20241030165330 do
   let(:batch_column) { 'id' }
   let(:sub_batch_size) { 2 }
   let(:pause_ms) { 0 }
-- 
GitLab