Skip to content

Commit e968cfd

Browse files
authored
fix: renumber migrations to fix staging deployment (#592)
## Summary Fixes staging deployment by renumbering migrations to match what staging has already applied. ## Problem Staging already applied migration 008 (metadata separation) before we inserted the new cleanup migration. When we added the cleanup as 008 and renumbered metadata to 009, staging tried to apply 009 again and failed with "column already exists". ## Current State - **Staging**: Has run original 008 (metadata separation), marked as complete. Failed trying to run 009 (which is the same migration renumbered). - **Production**: Has not run either 008 or 009 yet. ## Solution - Rename `008_clean_invalid_data.sql` → `007a_clean_invalid_data.sql` - Rename `009_separate_official_metadata.sql` → `008_separate_official_metadata.sql` (back to original) ## How This Fixes It With this renumbering: 1. **Staging behavior**: - Sees 008 is already complete (the metadata migration it already ran) - Sees 007a as new and runs it, but it will be a no-op (skips because staging doesn't have the problematic production data) - Continues normally 2. **Production behavior**: - Runs 007a (cleanup migration) - removes invalid data - Runs 008 (metadata separation) - applies successfully because data is now clean - Both migrations run in the correct order as intended ## Testing - Verified migration order works correctly - Tested on empty database (test environment) - 007a skips as expected - Tested with production data snapshot - 007a cleans data, 008 applies successfully This is a critical fix to unblock staging deployment.
1 parent 272ee93 commit e968cfd

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

internal/database/migrations/008_clean_invalid_data.sql renamed to internal/database/migrations/007a_clean_invalid_data.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
-- Migration 008: Clean up invalid data before applying stricter constraints in migration 009
1+
-- Migration 007a: Clean up invalid data before applying stricter constraints in migration 008
22
-- This migration removes or fixes data that would violate constraints introduced in the next migration
33

44
BEGIN;
@@ -27,11 +27,11 @@ BEGIN
2727

2828
-- Skip migration if we don't have the known bad data (indicates test environment)
2929
IF NOT has_known_bad_server THEN
30-
RAISE NOTICE 'Migration 008: Skipping cleanup - no known problematic data found (likely test/dev environment)';
30+
RAISE NOTICE 'Migration 007a: Skipping cleanup - no known problematic data found (likely test/dev environment)';
3131
RETURN; -- Exit early, don't run any cleanup
3232
END IF;
3333

34-
RAISE NOTICE 'Migration 008: Found known problematic data, proceeding with cleanup';
34+
RAISE NOTICE 'Migration 007a: Found known problematic data, proceeding with cleanup';
3535

3636
-- Count servers with invalid name format
3737
SELECT COUNT(*) INTO invalid_name_count
@@ -67,7 +67,7 @@ BEGIN
6767
OR value->>'version' = '';
6868

6969
-- Log the cleanup operations with safety check
70-
RAISE NOTICE 'Migration 008 Data Cleanup Plan:';
70+
RAISE NOTICE 'Migration 007a Data Cleanup Plan:';
7171
RAISE NOTICE ' Total servers in database: %', total_servers;
7272

7373
IF total_servers > 0 THEN

internal/database/migrations/009_separate_official_metadata.sql renamed to internal/database/migrations/008_separate_official_metadata.sql

File renamed without changes.

0 commit comments

Comments
 (0)