Skip to content

schemichq/schemic

Repository files navigation

Schemic — schema-as-code for any database, in the Zod you already know

Docs  •  Drivers  •  GitHub

npm   CI   license: MIT


Schemic lets you define your database schema once in TypeScript — with the Zod API you already know — and turns that single definition into your database's native DDL, end-to-end types, and reviewable migrations.

The engine and CLI are dialect-neutral; each database is an installable driver, so the same schema targets any of them. One source of truth — no separate ORM model, no code generation, no drift.

Drivers

More drivers are planned. The authoring API and the CLI are the same across every driver — only the generated DDL differs.

Packages

Package What it is
@schemic/core The dialect-neutral engine: the Driver contract, the portable schema IR, and the migration / diff / snapshot engine. Zero dialect code.
@schemic/cli The schemic / sc binary — also dialect-neutral; loads your driver from config.driver.
@schemic/<driver> A database driver: connection, authoring, and the dialect's DDL. See Drivers for the available ones.

The workflow

Author your schema, then drive it from the dialect-neutral CLI (sc is the short alias):

sc init        # scaffold a project: schemic.config.ts + schema + .env.example
sc diff        # preview changes vs the last snapshot   (--ts for a TypeScript view)
sc gen         # write a migration for the pending change
sc migrate     # apply pending migrations
sc status      # show applied vs pending migrations
sc pull        # introspect a live database back into TypeScript

The authoring API and the DDL it generates are driver-specific — see your driver's README for the exact builders and output.

Status

Alpha (0.x). APIs may still change.

  • SurrealDB driver — the most complete · coverage
  • PostgreSQL driver — in progress · coverage
  • more drivers

Development

A Bun workspaces monorepo (packages/*).

bun install
bun --filter '@schemic/*' test       # run every package's tests
bun --filter '@schemic/*' typecheck

License

MIT © Vertio Solutions

About

Schemic — schema-as-code, types, and migrations for any database (TypeScript). Author with s.*, target SurrealDB or Postgres.

Topics

Resources

License

Stars

25 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors