0.12.1 • Published 3 months ago

kysely-ctl v0.12.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

kysely-ctl is the official command-line tool for Kysely. We strive to make it TypeScript-first, cross-platform (macOS, Linux, and Windows), cross-runtime (Node.js, Bun, and Deno), and cross-module system (ESM and CommonJS) compatible. We also aim to have feature parity with Knex.js's CLI.

!NOTE This is a work in progress. Please report any issues you encounter or suggest any ideas you have in the issues section or in kysely's discord server.

Install

Prerequisites:

kysely-ctl requires kysely >= 0.18.1 to be installed.

Node.js:

npm i -D kysely-ctl

or:

yarn add -D kysely-ctl

or:

pnpm add -D kysely-ctl

Bun

bun add -D kysely-ctl

Deno

deno add -D npm:kysely-ctl

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, // a `Kysely` dialect instance OR the name of an underlying driver library (e.g. `'pg'`).
  dialectConfig, // optional. when `dialect` is the name of an underlying driver library, `dialectConfig` is the options passed to the Kysely dialect that matches that library.
  migrations: { // optional.
    allowJS, // optional. controls whether `.js`, `.cjs` or `.mjs` migrations are allowed. default is `false`.
    getMigrationPrefix, // optional. a function that returns a migration prefix. affects `migrate make` command. default is `() => ${Date.now()}_`.
    migrationFolder, // optional. name of migrations folder. default is `'migrations'`.
    migrator, // optional. a `Kysely` migrator instance. default is `Kysely`'s `Migrator`.
    provider, // optional. a `Kysely` migration provider instance. default is `kysely-ctl`'s `TSFileMigrationProvider`.
  },
  plugins, // optional. `Kysely` plugins list. default is `[]`.
  seeds: { // optional.
    allowJS, // optional. controls whether `.js`, `.cjs` or `.mjs` seeds are allowed. default is `false`.
    getSeedPrefix, // optional. a function that returns a seed prefix. affects `seed make` command. default is `() => ${Date.now()}_`.
    provider, // optional. a seed provider instance. default is `kysely-ctl`'s `FileSeedProvider`.
    seeder, // optional. a seeder instance. default is `kysely-ctl`'s `Seeder`.
    seedFolder, // optional. name of seeds folder. default is `'seeds'`.
  }
});

Alternatively, you can pass a Kysely instance, instead of dialect, dialectConfig & plugins:

import { defineConfig } from "kysely-ctl";
import { kysely } from 'path/to/kysely/instance';

export default defineConfig({
  // ...
  kysely,
  // ...
});

To use Knex's timestamp prefixes:

import { defineConfig, getKnexTimestampPrefix } from "kysely-ctl";

export default defineConfig({
  // ...
  migrations: {
    // ...
    getMigrationPrefix: getKnexTimestampPrefix,
    // ...
  },
  // ...
});

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".

Seed

The seed module mirrors Knex.js CLI's module of the same name.

knex seed:<command>

Can now be called as either:

kysely seed:<command>

or

kysely seed <command>

!NOTE We also provide kysely seed list, which is not part of Knex.js CLI.

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.

0.11.0

4 months ago

0.10.1

6 months ago

0.12.0

3 months ago

0.11.1

4 months ago

0.12.1

3 months ago

0.10.0

6 months ago

0.8.9

11 months ago

0.8.8

11 months ago

0.8.5

1 year ago

0.8.4

1 year ago

0.8.7

12 months ago

0.8.6

12 months ago

0.8.11

11 months ago

0.8.10

11 months ago

0.8.1-beta.1

1 year ago

0.8.1-beta.2

1 year ago

0.9.0

11 months ago

0.8.1

1 year ago

0.8.0

1 year ago

0.7.1

1 year ago

0.8.3

1 year ago

0.8.2

1 year ago

0.5.0

1 year ago

0.4.1

1 year ago

0.7.0

1 year ago

0.6.0

1 year ago

0.4.0

1 year ago

0.3.0

1 year ago

0.1.0

1 year ago

0.1.2

1 year ago

0.2.0

1 year ago

0.1.1

1 year ago

0.0.0

1 year ago