🐛 fix(ci): add db:push fallback when migrations fail

If db:migrate fails (e.g., due to migration hash mismatch after
modifying an already-applied migration), fall back to db:push
which syncs the schema directly.

This ensures the database schema is always up-to-date even when
migration tracking gets out of sync.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Wuesteon 2025-12-18 23:26:10 +01:00
parent ffc41b2b1d
commit f834986a82

View file

@ -280,12 +280,17 @@ jobs:
if docker compose exec -T mana-core-auth test -f src/db/migrate.ts 2>/dev/null || \
docker compose exec -T mana-core-auth pnpm run db:migrate --help 2>/dev/null; then
run_migration mana-core-auth || {
echo "❌ mana-core-auth migration failed - aborting deployment"
exit 1
echo "⚠️ mana-core-auth migration failed - falling back to db:push"
echo " This syncs schema directly, bypassing migration tracking"
docker compose exec -T mana-core-auth pnpm run db:push || {
echo "❌ mana-core-auth db:push also failed - aborting deployment"
exit 1
}
echo "✅ [mana-core-auth] Schema synced via db:push"
}
else
echo "⏭️ [mana-core-auth] No db:migrate script, using db:push..."
docker compose exec -T mana-core-auth npx drizzle-kit push --force || echo "Auth schema push completed"
docker compose exec -T mana-core-auth pnpm run db:push || echo "Auth schema push completed"
fi
echo ""