Warning
shki is still a work in progress. Declarative Schema support is active, but some deeper diff/render coverage and validation workflows are still being built.
shki manages database schema change by comparing an intended database shape
with recorded schema history and producing migration artifacts. It is SQL-first
and Drizzle-inspired:
- You author a Declarative Schema in SQL.
shkicompiles it in a disposable Shadow Database.- The resulting Snapshot is compared with the latest recorded Snapshot from the Journal.
shki diffpreviews the Migration Plan.shki generatewrites migration SQL, a new Snapshot, and a Journal entry.shki migrateapplies migration artifacts to the live database.
It also generates Rust/TypeScript/Protobuf types from that schema, and
type-safe sqlx query functions from annotated SQL.
📖 Documentation: https://dk0d.github.io/shki
# macOS and Linux
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/dk0d/shki/releases/latest/download/shki-installer.sh | sh# Windows (PowerShell)
irm https://github.com/dk0d/shki/releases/latest/download/shki-installer.ps1 | iexAlso available via cargo binstall --git https://github.com/dk0d/shki shki or
cargo install --git https://github.com/dk0d/shki. See the
installation guide.
shki init db --dialect postgres # scaffold shki.toml, schema/, migrations/
export DATABASE_URL='postgres://user:pass@localhost:5432/mydb'
$EDITOR db/schema/main.sql # write the schema you want
shki diff # preview the Migration Plan
shki generate create_users --down # write migration SQL + Snapshot + Journal entry
shki migrate # apply pending migrationsNo PostgreSQL install is needed for the Shadow Database — shki manages an
embedded one by default. Full walkthrough:
Quick Start.
| Workflow | PostgreSQL | MySQL | SQLite |
|---|---|---|---|
| Apply/status/down migration runner | yes | yes | yes |
| Custom Migration creation | yes | yes | yes |
| Dump live shape as SQL/JSON | yes | yes | yes |
| Dump live shape as Directory Schema | yes | yes | yes |
| Declarative Schema compile/diff/generate | yes | no | planned |
| Rich Catalog introspection coverage | strongest | basic | basic |
| Topic | What's there |
|---|---|
| How it works | Declarative Schema, Shadow Database, Snapshots, Journal |
| Declarative Schema | Shadow Database setup, extensions, multi-file schemas |
| Migrations | diff, generate, Custom Migrations, apply, adopt, roll back |
| Code generation | Rust, TypeScript, and Protobuf types from schema shape |
| Typed queries | type-safe sqlx functions from annotated SQL |
| CLI reference | every command, flag, and alias |
| Configuration | shki.toml keys and environment variables |
Issues and pull requests are welcome. See Contributing for the dev setup and test workflow.
MIT, see LICENSE.
shki stands on the shoulders of projects that explored these ideas first —
full credits in Inspired By:
- pgschema — declarative, Terraform-style schema management for PostgreSQL.
- jayy-lmao/sql-gen — generating typed Rust code from a live database schema.
- squirrel — type-safe SQL code generation from introspected queries.
- goose — a database migration tool. Supports SQL migrations and Go functions.