database-migrations
Database Migrations with @schemavaults/dbh
@schemavaults/dbh provides Kysely migrations for
PostgreSQL, applied through the dbh CLI. Migrations are opinionated: every file
is a numbered module that exports an up() and a down() function. TypeScript
source migrations are built to JavaScript first, then applied with the
CLI.
Invoke the CLI with your package runner. Use bunx @schemavaults/dbh for
validating and building migrations — build-db-migrations uses Bun's
bundler and requires Bun anyway. Use npx @schemavaults/dbh for running /
applying migrations (migrate and reverse): most PostgreSQL drivers are
built for Node.js rather than Bun, so apply migrations on the Node runtime.
One-time setup (for consumers)
Migrations import the sql template tag from @/sql rather than directly from
the package. This indirection is required by the build step (see the note under
"Building migrations"), so configure it once: