feat(supabase): db:sandbox migrate, forward only on the running sandbox

This commit is contained in:
bchanot committed 2026-11-16 14:33:10 +01:00
1 parent f3712b2baa
commit 21c9a81e0c
2 files changed
+14

No files matched your search

+1
View File
@@ -806,6 +806,7 @@ Docker.
| `pnpm db:sandbox verify-e2e` | V1-2.3: a gateway (`nginx:1.31-alpine`, sandbox network only, no host port) and the real verification worker `faunosteo_worker:dev run --jobs sheet-verify` against the sandbox, then `packages/supabase/tests/sandbox/sheet-verification.sandbox.ts`; both containers removed at the end, the service key passed through a 600 file deleted at start |
| `pnpm db:sandbox avatar-e2e` | V1-2.3: the same gateway, published on `127.0.0.1:57800` only and routing `/auth/v1/` too, the real worker `faunosteo_worker:dev run` (default mode: avatars and sweep, 5 s sweep, no quarantine grace, 512 MiB as the compose `worker`) against the sandbox, then `packages/supabase/tests/e2e/avatar-flow.e2e.ts` through that port; the suite's psql calls go to the sandbox database container, which it requires by name; its two accounts are made per run with random passwords and deleted after; both containers removed at the end |
| `pnpm db:sandbox trial` / `trial-account <email>` / `trial-grant <email> <kind>` | V1-2.6 owner trial (`docs/development/V1-2-6_OWNER_TRIAL.md`): the app on `http://$FAUNOSTEO_TRIAL_HOST:5193` (default the LAN address of this machine, `127.0.0.1` = host-only; loopback or private IPv4 of an interface only, Host header allowlisted) behind a trial gateway on `127.0.0.1:57801` (refuses to start when `faunosteo_dbsandbox_trial_gateway` exists), a confirmed account (hidden password prompt), a catalogue right (email and kind checked, passed as psql variables; editor and publisher also get the admin role) |
| `pnpm db:sandbox migrate` | forward only on the running sandbox: `supabase migration up --db-url` applies the branch's pending migrations, nothing else (no reset, no seed, no container recreated, data kept); prints the last applied version before and after, a second run applies nothing |
| `pnpm db:sandbox sql` / `down` | psql as postgres on stdin / remove the stack |
Every CLI call passes `--db-url` with `sslmode=disable` (the sandbox has no
+13
View File
@@ -265,6 +265,18 @@ cmd_up() {
echo "== sandbox up ($mode): db 127.0.0.1:$PORT_DB, auth :$PORT_AUTH, rest :$PORT_REST, mail :$PORT_MAIL"
}
# pnpm db:sandbox migrate: forward only, on the running sandbox; the branch's
# pending migrations and nothing else (no reset, no seed, no container recreated).
cmd_migrate() {
[ $# -eq 0 ] || die "migrate takes no argument"
docker ps --format '{{.Names}}' | grep -qx "$DB" || die "sandbox not up (pnpm db:sandbox up fresh)"
load_secrets
local last='select max(version) from supabase_migrations.schema_migrations'
echo "== before: $(sb_psql -t -A -c "$last")"
migrate_up .
echo "== after: $(sb_psql -t -A -c "$last")"
}
cmd_down() {
docker rm -f "$AVATAR_WORKER" "$WORKER" "$TRIAL_GATEWAY" "$GATEWAY" "$REST" "$STORAGE" "$AUTH" "$MAIL" "$DB" >/dev/null 2>&1 || true
docker network rm "$NET" >/dev/null 2>&1 || true
@@ -521,6 +533,7 @@ case "${1:-}" in
trial) cmd_trial ;;
trial-account) shift; cmd_trial_account "$@" ;;
trial-grant) shift; cmd_trial_grant "$@" ;;
migrate) shift; cmd_migrate "$@" ;;
sql) load_secrets; sb_psql ;;
*) sed -n '2,36p' "$0"; exit 1 ;;
esac