CLI
db
Run SQL files against the local stack or another database.
query
pnpm better-supabase db query supabase/tests/seed.sql supabase/tests/more.sql
pnpm better-supabase db query --single-transaction a.sql b.sqldb query runs each file as one script, in the order you pass them. A file
can hold many statements, so a data migration or a fixture file runs as it
would in psql -f, without a psql install.
| Flag | Effect |
|---|---|
--single-transaction | Wraps every file in one transaction, so a failure keeps none. |
--stack <name> | Uses the database of supabase/stacks/<name>/config.toml (default $BSB_STACK). |
--db-url-stdin | Reads the connection string from stdin, so it never reaches argv. |
Without --db-url-stdin, the command connects through $DATABASE_URL,
$SUPABASE_DB_URL, or the local stack. Against a database that is not local,
an agent needs the user's consent first. A failing file stops the run, and
the error names it. The JSON envelope lists the files that ran in data.ran.
Side effects: Writes to the database.
Last updated on