Skip to content

Quick Start

Terminal window
shki init db --dialect postgres

init creates a project layout like:

db/
shki.toml
postgres-language-server.jsonc
schema/
main.sql
migrations/
_meta/

For PostgreSQL projects, postgres-language-server.jsonc is generated from the same init defaults so editor tooling points at the Declarative Schema entrypoint.

Terminal window
export DATABASE_URL='postgres://user:pass@localhost:5432/mydb'
-- db/schema/main.sql
CREATE TABLE users (
id integer PRIMARY KEY,
email text NOT NULL UNIQUE
);
Terminal window
shki diff
Terminal window
shki generate create_users --down

This writes the migration SQL, its Snapshot, and a Journal entry (plus a Down Migration, thanks to --down):

db/migrations/
0000_create_users.sql
0000_create_users.down.sql
_meta/
0000_create_users.snapshot.json
_journal.json

Commit all of it — the Snapshot is the baseline the next diff compares against.

Terminal window
shki migrate # everything pending
shki migrate --dry # or preview first

migrate runs each pending file and records it, with its checksum, in the migrations table. Check where things stand at any point:

Terminal window
shki status

Steps 3–6 are the loop: edit the schema, diff, generate, migrate.