"__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:**
  • **AUTO_INCREMENT Gap**: Jumped from ID 25 to ID 49 (skipping 26-48)
  • **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 sequenceUPDATE __drizzle_migrations SET id = 26 WHERE id = 49;-- Added missing migrationINSERT INTO __drizzle_migrations (id, hash, created_at) VALUES (27, '[hash]', UNIX_TIMESTAMP() * 1000);Questions:
  • Has anyone else experienced issues with PlanetScale branch promotions not copying migration data?
  • 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 promotion
Was this page helpful?