CLI commands
The CLI ships as schemic, with sc as a short alias. Run any command with npx schemic <command>. Commands that talk to a database accept the global connection flags and read defaults from schemic.config.ts.
Setup
schemic init
Scaffold the database/ layout, a config file, a sample schema, and an empty migration snapshot. Never overwrites existing files.
schemic doctor
Print the resolved configuration and test the database connection.
Migrations
schemic gen [name]
Diff the schema against the snapshot and write a migration for the difference. Writes nothing when there are no changes.
schemic migrate [count]
Apply pending migrations in order — all, the next N, or up to a tag. Alias: up.
schemic rollback [count]
Revert applied migrations newest-first. Alias: down.
schemic status
Show applied vs pending migrations, flagging files that changed after apply or are missing.
schemic new <name>
Scaffold a blank, hand-written .surql migration with up/down branches.
schemic check
Replay migrations in a throwaway engine and confirm they reproduce the schema. Exits non-zero on mismatch.
schemic snapshot reset
Clear the migration snapshot so the next schemic gen baselines the full schema.
schemic unlock
Release a stale migration lock left by an interrupted run.
Live database
schemic diff
Preview the pending change without writing a migration. Diffs against the snapshot, or a live database with --live.
schemic push
Apply the schema directly to the database, no migration files. Alias: sync. Prunes stale objects by default.
schemic pull
Introspect the database and update your s.* files to match. Previews by default; non-destructive.
schemic seed
Run the project's seed script (database/seed.ts) with a connected client.
Global flags
These apply to every command that connects to a database. Each overrides the matching schemic.config.ts value, which in turn falls back to environment variables.
| Flag | Description |
|---|---|
--url <url> | Database endpoint, e.g. ws://localhost:8000. |
--namespace <ns> | Target namespace. |
--database <db> | Target database. |
--username <user> | Auth username. |
--password <pass> | Auth password. |
--auth-level <level> | Sign-in level: root, namespace, or database. |
-c, --config <path> | Path to the config file. |
--[no-]tables | Include or exclude tables from the operation. |
--[no-]functions | Include or exclude functions. |
--[no-]access | Include or exclude access definitions. |
Where to go next
- Generate & run migrations — the workflow these commands support.
- Configuration — the config file in full.
- The migration model — migrate vs push vs pull.