"__drizzle_migrations AUTO_INCREMENT gap + missing entry after PlanetScale branch promotion"
We're using Drizzle with PlanetScale and encountered a migration failure caused by two issues during branch promotion.
The Problem:
- Migration 0026 failed with:
Table 'video' already exists
- The table existed but migration wasn't tracked in __drizzle_migrations
Root Cause - Two Issues:
1. AUTO_INCREMENT Gap: Jumped from ID 25 to ID 49 (skipping 26-48)
2. Missing Migration Record: When promoting from dev → staging branch in PlanetScale:
- Schema changes (video table) were copied
- But the __drizzle_migrations
entry for migration 0026 was NOT copied
- Even though "Automatically copy migration data" was enabled
Result:
- Staging branch had the video table but no migration record
- Drizzle tried to re-run migration 0026, causing the error
Solution:
```sql
-- Fixed the sequence
UPDATE drizzle_migrations SET id = 26 WHERE id = 49;
-- Added missing migration
INSERT INTO drizzle_migrations (id, hash, created_at)
VALUES (27, '[hash]', UNIX_TIMESTAMP() * 1000);
Questions:
1. Has anyone else experienced issues with PlanetScale branch promotions not copying migration data?
2. Should Drizzle have better handling for these branch promotion scenarios?
Environment:
- Drizzle ORM: 0.38.3
- Database: PlanetScale (using branches)
- Issue occurred during: dev → staging branch promotion0 Replies