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 init --driver postgres
FLAG TYPE DESCRIPTION
--driver postgres string Scaffold a Postgres project.

schemic doctor

Print the resolved configuration and test the database connection.

$ schemic doctor
FLAG TYPE DESCRIPTION

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.

$ schemic new table invoice
FLAG TYPE DESCRIPTION

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 diff
FLAG TYPE DESCRIPTION

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 gen add_invoice
FLAG TYPE DESCRIPTION

schemic migrate [count]

Apply pending migrations in order against the embedded PGlite database. Alias: up.

$ schemic migrate
FLAG TYPE DESCRIPTION

schemic rollback [count]

Revert applied migrations newest-first, running each migration's down section. Alias: down.

$ schemic rollback 2
FLAG TYPE DESCRIPTION

schemic status

Show applied vs pending migrations.

$ schemic status
FLAG TYPE DESCRIPTION

schemic unlock

Release a stale migration lock left by an interrupted run.

$ schemic unlock
FLAG TYPE DESCRIPTION

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 seed [name] [--all]
FLAG TYPE DESCRIPTION
[name] string Run the single named seed (its filename without the NN- ordering prefix).
--all boolean Run every seed in database/seed/ in filename order, even when an index.ts is present.

schemic check --schema

Validate your schema definitions. On Postgres, check supports schema validation only — full migration replay is not yet available.

$ schemic check --schema
FLAG TYPE DESCRIPTION
--schema boolean Validate the schema. Required on the Postgres driver.

Not yet supported on Postgres

These commands exist on other drivers but error on Postgres with “the postgres driver does not support …”:

CommandStatus
schemic pullNo 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):

FlagBehaviour on Postgres
schemic diff --liveNo-op — pg diff already runs against the live database.
schemic diff --tsNo-op — pg diff does not render TypeScript.
schemic diff --watchNo-op — watch mode does not apply.

Global flags

FlagDescription
--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).
--allRun against every connection in your config.

Where to go next