kysely-ctl
is the official command-line tool for Kysely. We strive to make it TypeScript-first, cross-platform (macOS, Linux, and Windows), and cross-runtime (Node.js, Bun, and Deno) compatible. We also aim to have feature parity with Knex.js's CLI.
Install
npm i -D kysely-ctl
Make sure the following dependencies are also installed:
kysely - pretty obvious.
c12 - used to load the kysely.config.ts
file in your project.
citty - used to build and run the CLI.
consola - used for output.
nypm - used to detect package manager.
pathe - used anywhere node:path
module would've been used.
pkg-types - used to read package.json
files.
tsx - used to import TS migration files (required only for Node.js as Bun/Deno support importing TS files out the box).
Use
Configuration
Currently, a kysely.config.ts
file is required, in the project root OR .config
folder. Run kysely init
in your terminal to create one.
import { defineConfig } from "kysely-ctl";
export default defineConfig({
dialect,
dialectConfig,
migrations: {
migrationFolder,
migrator,
provider,
},
plugins,
});
Commands
For more information run kysely -h
in your terminal.
Migrate
The migrate
module mirrors Knex.js CLI's module of the same name.
knex migrate:<command>
Can now be called as either:
kysely migrate:<command>
or
kysely migrate <command>
[!NOTE]
rollback
without --all
flag is not supported, as Kysely doesn't keep track of "migration batches".
Acknowledgements
acro5piano who built kysely-migration-cli and inspired this project.
UnJS's amazing tools that help power this project.
Knex.js team for paving the way.