inspectandselfcheck;verify;migrations;sync;doctor.
supaschema init reuses existing database URL environment variable names from .env* files in sync.targets when it can identify them. Configure named environments only when you need an extra named target.
Resolution order
- An explicit value — the
--database-urlflag or adatabase:<url>source in non-generation workflows. - A named environment — the global
--env <name>flag readsenvironments.<name>.databaseUrlfrom config. SUPASCHEMA_DATABASE_URL— the environment variable, when set.- The local Supabase stack — for Supabase projects only, the nearest
supabase/config.toml(searched upward from the working directory) supplies the local URL from its[db] port. Other providers should use named environments orSUPASCHEMA_DATABASE_URL.
$ENV_NAME indirection. If the environment variable is missing, supaschema fails loudly.
supabase/config.toml is read only to discover the local Supabase database
URL. Supabase installs also default sync targets to the Supabase CLI runner,
so existing Supabase CLI project link and authentication state remain the
apply credential lane. Other provider config or infrastructure files are
install-time markers only. Schema locations and sync target references come
from supaschema.config.json.Named environments
Define extra targets insupaschema.config.json and select them per run with --env:
Sync targets
sync.targets names the apply or deploy targets that supaschema sync can reconcile. A target may set databaseUrl, reference a named environment, or omit both to use the runner/default database URL fallback.
mode: "auto" makes a target selectable by bare supaschema sync when workflow.migration_sync is "auto". Keep at most one target automatic; sync refuses multiple selected targets because cross-target apply is not atomic. Remote targets also require a runtime approval variable such as SUPASCHEMA_REMOTE_SYNC_APPROVED=1 before automatic deploy.
Remote targets and verify
verify creates and drops throwaway databases, so it refuses non-local hosts unless you explicitly opt in with SUPASCHEMA_VERIFY_ALLOW_REMOTE=1. The role it connects with must have CREATEDB; a capability preflight fails fast when it does not.
Diagnosing resolution
supaschema doctor prints which resolution lane produced the URL, whether the database is reachable, and whether the role has CREATEDB — the first stop when a command can’t find or reach a database. Diagnostics redact credentials (URL passwords, JWTs, secrets) before printing.
