From 6717cbce352496fb3fce11d2fb53ae155e9aa65c Mon Sep 17 00:00:00 2001
From: Brian Williams <bwilliams@gitlab.com>
Date: Wed, 30 Oct 2024 11:43:57 -0500
Subject: [PATCH] Convert 20241022181600 to a schema migration

This migration caused the BBM to begin erroring on .com because
application code is updated _before_ post-deployment migrations run. For
.com the issue was addressed by pausing the migration until the
post-deployment migrations were able to run an delete it. This change
converts the migration to a schema migration so that the same issue does
not happen during self-managed upgrades.

Changelog: fixed
---
 ...e_backfill_vulnerability_occurrence_pipelines_project_id.rb | 3 +++
 1 file changed, 3 insertions(+)
 rename db/{post_migrate => migrate}/20241022181600_remove_backfill_vulnerability_occurrence_pipelines_project_id.rb (72%)

diff --git a/db/post_migrate/20241022181600_remove_backfill_vulnerability_occurrence_pipelines_project_id.rb b/db/migrate/20241022181600_remove_backfill_vulnerability_occurrence_pipelines_project_id.rb
similarity index 72%
rename from db/post_migrate/20241022181600_remove_backfill_vulnerability_occurrence_pipelines_project_id.rb
rename to db/migrate/20241022181600_remove_backfill_vulnerability_occurrence_pipelines_project_id.rb
index 3a30ce9b0678..8fcaadaaee2f 100644
--- a/db/post_migrate/20241022181600_remove_backfill_vulnerability_occurrence_pipelines_project_id.rb
+++ b/db/migrate/20241022181600_remove_backfill_vulnerability_occurrence_pipelines_project_id.rb
@@ -7,6 +7,8 @@ class RemoveBackfillVulnerabilityOccurrencePipelinesProjectId < Gitlab::Database
   MIGRATION = "BackfillVulnerabilityOccurrencePipelinesProjectId"
 
   def up
+    # rubocop:disable Migration/BatchMigrationsPostOnly -- Must be run before BBM code is deleted.
+    # Estimated runtime on .com is only 5 seconds.
     delete_batched_background_migration(
       MIGRATION,
       :vulnerability_occurrence_pipelines,
@@ -18,6 +20,7 @@ def up
         :occurrence_id
       ]
     )
+    # rubocop:enable Migration/BatchMigrationsPostOnly
   end
 
   def down
-- 
GitLab