Add migrate.sh script to easily run db migration/seed in production

This commit is contained in:
Dominic Ferrando
2026-08-14 13:04:31 -04:00
parent 37787ff0dd
commit ae88415406
2 changed files with 72 additions and 0 deletions
+20
View File
@@ -57,3 +57,23 @@ this directory:
Deployed to Fly.io (`fly.toml`). After a domain changes, re-run
`src/scripts/register-webhooks.ts` with production env vars to point Printful's
and Webflow's webhooks at the new domain — see issue #3 for the full checklist.
### Running migrations/seed against production
The deployed image only contains the compiled binary (see `Dockerfile`) — no
source, no `bun_modules`, no migration files — so these can't be run from
`fly ssh console` on the API app itself. Instead, use `migrate.sh` at the repo
root, which tunnels to the Postgres app (`blade-and-brawn-db`, legacy/unmanaged
Fly Postgres) via `fly proxy`, fetches the production `DATABASE_URL` for you,
and runs the scripts against it:
```bash
./migrate.sh migrate # db:migrate:latest (default if no argument given)
./migrate.sh seed # db:seed
./migrate.sh both # both, in order
```
Both underlying scripts prompt for a `y/N` confirmation before touching the
database, and `db:seed` is idempotent (skips seeding if the default rows
already exist). If the tunneled connection fails on TLS, legacy Postgres
sometimes needs `?sslmode=disable` appended — edit `migrate.sh` if so.