Database migrations are the riskiest deployment step. A bad migration can:
Lock tables for extended periods
Corrupt or delete data
Break the application with schema mismatches
Platform-Specific Branching
Neon (PostgreSQL)
# Create a branch from productionneonctl branches create --name migration-test --parent main# Apply and test migrationpsql $BRANCH_URL -f migration.sql# If good, apply to mainpsql $MAIN_URL -f migration.sql# Clean upneonctl branches delete migration-test
PlanetScale (MySQL)
# Create a branchpscale branch create mydb migration-test# Apply schema changespscale shell mydb migration-test < migration.sql# Create a deploy request (like a PR for your schema)pscale deploy-request create mydb migration-test# Review and deploypscale deploy-request deploy mydb 1
Supabase
# Use linked project branching (preview branches)supabase branches create migration-test# Or use local for testingsupabase startsupabase db push # Test locally first