diff --git a/CLAUDE.md b/CLAUDE.md index 0e2ecb3..3f46903 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -406,4 +406,34 @@ npx prisma migrate resolve --applied - Apply Prisma migrations: `npx prisma migrate deploy` - Restart: `pm2 restart app-ts --update-env` +### Hotfixing a migration that was added after the tarball was built + +If you write a new `prisma/migrations/_*` folder **after** the +release tarball has already been built and shipped, that migration is +NOT in the tarball and `prisma migrate deploy` on prod will report +"No pending migrations". The release tarball re-build re-runs the whole +release, but for a one-off hotfix you can ship just the new migration +folder: + +```bash +# Local +cd prisma/migrations +tar -czf /tmp/warehouse_perms_migration.tar.gz _/ +scp /tmp/warehouse_perms_migration.tar.gz boha_admin@192.168.50.100:/tmp/ + +# On prod +ssh boha_admin@192.168.50.100 +cd /var/www/app-ts/prisma/migrations +sudo -u boha_admin tar -xzf /tmp/warehouse_perms_migration.tar.gz +cd /var/www/app-ts +npx prisma migrate deploy +pm2 restart app-ts --update-env +``` + +The migration is still tracked in git and applied via `prisma migrate +deploy` — the only thing the tarball is doing is delivering the +`migration.sql` to prod, which is the same mechanism the main release +uses. This is preferred over running raw SQL on prod (which the policy +in "Database Migrations" forbids). + Do not push directly to production or restart services without confirmation.