CLI commands
The CLI ships as schemic, with sc as a short alias. Run any command with npx schemic <command> (bunx schemic with Bun, pnpm dlx schemic with pnpm). Commands read defaults from schemic.config.ts.
The Postgres workflow is author → diff → gen → migrate, with status, rollback, and seed rounding it out.
Setup
schemic init --driver postgres
Scaffold the database/ layout, a config file, a sample schema, a seed file, and an empty migration snapshot. Never overwrites existing files.
schemic doctor
Print the resolved configuration and test the database connection.
schemic new <kind> <name>
Scaffold a starter schema file at <schema>/<kind-folder>/<name>.ts — a realistic starter, not a bare stub. On Postgres, new scaffolds a table starter (→ tables/); index and constraint give an 'authored inside a table' message, since indexes and foreign keys live in defineTable. Postgres' other standalone objects — enums, views, sequences, domains, extensions, functions, triggers, policies — are authored by hand with defineX (no new scaffolder for them yet). Requires a directory schema layout; never overwrites an existing file.
Migrations
schemic diff
Preview the pending structural change by introspecting the live database, without writing a migration. Structural only; --live, --ts, and --watch are SurrealDB-only flags.
schemic gen [name]
Diff the schema against the snapshot and write a migration for the difference. Writes nothing when there are no changes. Alias: generate.
schemic migrate [count]
Apply pending migrations in order against the embedded PGlite database. Alias: up.
schemic rollback [count]
Revert applied migrations newest-first, running each migration's down section. Alias: down.
schemic status
Show applied vs pending migrations.
schemic unlock
Release a stale migration lock left by an interrupted run.
Data & validation
schemic seed [name]
Run the project's seeds against a connection. Seeds live in database/seed/: bare schemic seed runs database/seed/index.ts (or every seed in filename order if there is none), a name runs one seed, and --all runs them all. A flat database/seed.ts still works as a single seed.
schemic check --schema
Validate your schema definitions. On Postgres, check supports schema validation only — full migration replay is not yet available.
Not yet supported on Postgres
These commands exist on other drivers but error on Postgres with “the postgres driver does not support …”:
| Command | Status |
|---|---|
schemic pull | No introspection-into-code yet. |
schemic push (sync) | No apply-without-migration yet. |
schemic check (full replay) | check validates the schema only — use --schema. |
These diff flags are accepted but ignored — Postgres diff is always structural and runs against the live database, so the flags are no-ops (they do not error):
| Flag | Behaviour on Postgres |
|---|---|
schemic diff --live | No-op — pg diff already runs against the live database. |
schemic diff --ts | No-op — pg diff does not render TypeScript. |
schemic diff --watch | No-op — watch mode does not apply. |
Global flags
| Flag | Description |
|---|---|
--url <url> | Override the connection’s PGlite location for this command (a file: data dir or empty for in-memory). |
-c, --config <path> | Path to the config file. |
--connection <name> | Run against a named connection from your config (default: default). |
--all | Run against every connection in your config. |
Where to go next
- Generate & run migrations — the workflow these commands support.
- Configuration — the config file in full.
- The migration model — why Postgres is migration-first.