{"id":19390905,"url":"https://github.com/kysely-org/kysely-ctl","last_synced_at":"2026-05-10T02:32:07.246Z","repository":{"id":238001205,"uuid":"792061162","full_name":"kysely-org/kysely-ctl","owner":"kysely-org","description":"Command-line tool for Kysely","archived":false,"fork":false,"pushed_at":"2025-04-19T22:23:28.000Z","size":700,"stargazers_count":175,"open_issues_count":13,"forks_count":10,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-07T15:51:46.508Z","etag":null,"topics":["automation","cli","ctl","knex","kysely","migrations","mssql","mysql","postgres","seeds","sql","sqlite"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kysely-org.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-04-25T22:43:22.000Z","updated_at":"2025-05-01T09:21:58.000Z","dependencies_parsed_at":"2024-05-11T15:43:52.049Z","dependency_job_id":"9afba53e-1e77-490a-8a32-f9a22c5ed8e6","html_url":"https://github.com/kysely-org/kysely-ctl","commit_stats":null,"previous_names":["kysely-org/kysely-ctl"],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kysely-org%2Fkysely-ctl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kysely-org%2Fkysely-ctl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kysely-org%2Fkysely-ctl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kysely-org%2Fkysely-ctl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kysely-org","download_url":"https://codeload.github.com/kysely-org/kysely-ctl/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254414493,"owners_count":22067271,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","cli","ctl","knex","kysely","migrations","mssql","mysql","postgres","seeds","sql","sqlite"],"created_at":"2024-11-10T10:23:54.722Z","updated_at":"2026-05-10T02:32:07.236Z","avatar_url":"https://github.com/kysely-org.png","language":"TypeScript","funding_links":[],"categories":["Projects by main language","TypeScript","\u003ca name=\"TypeScript\"\u003e\u003c/a\u003eTypeScript"],"sub_categories":["typescript"],"readme":"\u003cdiv style=\"width: 100%;\"\u003e\n  \u003cimg src=\"assets/banner.svg\" alt=\"kysely in the terminal\" width=\"100%\" /\u003e\n\u003c/div\u003e\n\n[![NPM Version](https://img.shields.io/npm/v/kysely-ctl?style=flat\u0026label=latest)](https://github.com/kysely-org/kysely-ctl/releases/latest)\n[![Tests](https://github.com/kysely-org/kysely-ctl/actions/workflows/test.yml/badge.svg)](https://github.com/kysely-org/kysely-ctl)\n[![License](https://img.shields.io/github/license/kysely-org/kysely-ctl?style=flat)](https://github.com/kysely-org/kysely-ctl/blob/master/LICENSE)\n[![Issues](https://img.shields.io/github/issues-closed/kysely-org/kysely-ctl?logo=github)](https://github.com/kysely-org/kysely-ctl/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc)\n[![Pull Requests](https://img.shields.io/github/issues-pr-closed/kysely-org/kysely-ctl?label=PRs\u0026logo=github\u0026style=flat)](https://github.com/kysely-org/kysely-ctl/pulls?q=is%3Apr+is%3Aopen+sort%3Aupdated-desc)\n![GitHub contributors](https://img.shields.io/github/contributors/kysely-org/kysely-ctl)\n[![Downloads](https://img.shields.io/npm/dw/kysely-ctl?logo=npm)](https://www.npmjs.com/package/kysely-ctl)\n\n###### Join the discussion ⠀⠀⠀⠀⠀⠀⠀\n[![Discord](https://img.shields.io/badge/Discord-%235865F2.svg?style=flat\u0026logo=discord\u0026logoColor=white)](https://discord.gg/xyBJ3GwvAm)\n[![Bluesky](https://img.shields.io/badge/Bluesky-0285FF?style=flat\u0026logo=Bluesky\u0026logoColor=white)](https://bsky.app/profile/kysely.dev)\n\n`kysely-ctl` is the official command-line tool for [Kysely](https://kysely.dev).\nWe strive to make it [TypeScript](https://www.typescriptlang.org/)-first, cross-platform\n([macOS](https://www.apple.com/macos), [Linux](https://www.linux.org/), and [Windows](https://www.microsoft.com/en-us/windows)),\ncross-runtime ([Node.js](https://nodejs.org/), [Bun](https://bun.sh/), and [Deno](https://deno.com/)),\nand cross-module system ([ESM](https://nodejs.org/api/esm.html#modules-ecmascript-modules)\nand [CommonJS](https://nodejs.org/api/modules.html#modules-commonjs-modules)) compatible.\nWe also aim to have feature parity with [Knex.js](https://knexjs.org)'s CLI.\n\n## Install\n\n### Prerequisites:\n\n`kysely-ctl` requires `kysely` \u003e= 0.18.1 to be installed in your project/s.\n\n### System-wide installation:\n\n\u003cdetails\u003e\n\u003csummary\u003eWhen installed globally, \u003ccode\u003ekysely-ctl\u003c/code\u003e will be available as \u003ccode\u003ekysely\u003c/code\u003e in your terminal,\nanywhere.\u003c/summary\u003e\n\n#### Node.js:\n\n```bash\nnpm i -g kysely-ctl\n```\n\nor:\n\n```bash\npnpm add -g kysely-ctl\n```\n\n#### Bun\n\n```bash\nbun add -g kysely-ctl\n```\n\n#### Deno\n\n```bash\ndeno install -g -f npm:kysely-ctl@latest\n```\n\u003c/details\u003e\n\n### Project-scoped installation:\n\n\u003cdetails\u003e\n\u003csummary\u003eAlternatively, you can install \u003ccode\u003ekysely-ctl\u003c/code\u003e in your project as a dev dependency,\nwhich will make it available as \u003ccode\u003ekysely\u003c/code\u003e in your project's \u003ccode\u003epackage.json\u003c/code\u003e:\u003c/summary\u003e\n\n#### Node.js:\n\n```bash\nnpm i -D kysely-ctl\n```\n\nor:\n\n```bash\nyarn add -D kysely-ctl\n```\n\nor:\n\n```bash\npnpm add -D kysely-ctl\n```\n\n#### Bun\n\n```bash\nbun add -D kysely-ctl\n```\n\n#### Deno\n\n```bash\ndeno add -D npm:kysely-ctl\n```\n\u003c/details\u003e\n\n## Use\n\n### Configuration\n\n\u003cdetails\u003e\n\u003csummary\u003eCurrently, a \u003ccode\u003ekysely.config.ts\u003c/code\u003e file is required, in the project root OR \u003ccode\u003e.config\u003c/code\u003e\nfolder. Run \u003ccode\u003ekysely init\u003c/code\u003e in your terminal to create one.\u003c/summary\u003e\n\n```ts\nimport { defineConfig } from \"kysely-ctl\";\n\nexport default defineConfig({\n  destroyOnExit, // optional. dictates whether the (resolved) `kysely` instance should be destroyed when a command is finished executing. default is `true`.\n  dialect, // a `Kysely` dialect instance OR the name of an underlying driver library (e.g. `'pg'`).\n  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.\n  migrations: { // optional.\n    allowJS, // optional. controls whether `.js`, `.cjs` or `.mjs` migrations are allowed. default is `false`.\n    getMigrationPrefix, // optional. a function that returns a migration prefix. affects `migrate make` command. default is `() =\u003e ${Date.now()}_`.\n    migrationFolder, // optional. path to where migration files are located. default is a folder named \"migrations\" next to the config file/folder.\n    migrator, // optional. a `Kysely` migrator instance factory of shape `(db: Kysely\u003cany\u003e) =\u003e Migrator | Promise\u003cMigrator\u003e`. default is `Kysely`'s `Migrator`.\n    provider, // optional. a `Kysely` migration provider instance. default is `kysely-ctl`'s `TSFileMigrationProvider`.\n  },\n  plugins, // optional. `Kysely` plugins list. default is `[]`.\n  seeds: { // optional.\n    allowJS, // optional. controls whether `.js`, `.cjs` or `.mjs` seeds are allowed. default is `false`.\n    getSeedPrefix, // optional. a function that returns a seed prefix. affects `seed make` command. default is `() =\u003e ${Date.now()}_`.\n    provider, // optional. a seed provider instance. default is `kysely-ctl`'s `FileSeedProvider`.\n    seeder, // optional. a seeder instance factory of shape `(db: Kysely\u003cany\u003e) =\u003e Seeder | Promise\u003cSeeder\u003e`. default is `kysely-ctl`'s `Seeder`.\n    seedFolder, // optional. path to where seed files are located. default is a folder named \"seeds\" next to the config file/folder.\n  }\n});\n```\n\n#### Reuse Kysely instance defined elsewhere\n\nYou can pass a `Kysely` instance, instead of `dialect`, `dialectConfig` \u0026 `plugins`:\n\n```ts\nimport { defineConfig } from \"kysely-ctl\";\nimport { kysely } from 'path/to/kysely/instance';\n\nexport default defineConfig({\n  destroyOnExit, // optional. dictates whether the `kysely` instance should be destroyed when a command is finished executing. default is `true`.\n  // ...\n  kysely,\n  // ...\n});\n```\n\n#### Custom migration/seed file prefixes\n\nTo use Knex's timestamp prefixes:\n\n```ts\nimport { defineConfig, getKnexTimestampPrefix } from \"kysely-ctl\";\n\nexport default defineConfig({\n  // ...\n  migrations: {\n    // ...\n    getMigrationPrefix: getKnexTimestampPrefix,\n    // ...\n  },\n  // ...\n});\n```\n\n#### Extending configuration\n\nSee [c12 docs](https://github.com/unjs/c12#extending-configuration) and the following [example](https://github.com/kysely-org/kysely-ctl/blob/main/examples/node-esm-multi-config/.config/kysely.test.config.ts).\n\n#### Environment-specific configuration\n\nSee [c12 docs](https://github.com/unjs/c12#environment-specific-configuration) and the following [example](https://github.com/kysely-org/kysely-ctl/blob/main/examples/node-esm-environments/.config/kysely.config.ts).\n\n\u003c/details\u003e\n\n### Commands\n\nFor more information run `kysely -h` in your terminal.\n\n#### Migrate\n\n\u003cdetails\u003e\n\u003csummary\u003eThe \u003ccode\u003emigrate\u003c/code\u003e module mirrors \u003ca href=\"https://knexjs.org\"\u003eKnex.js\u003c/a\u003e CLI's module of the\nsame name.\u003c/summary\u003e\n\n```bash\nknex migrate:\u003ccommand\u003e\n```\n\nCan now be called as either:\n\n```bash\nkysely migrate:\u003ccommand\u003e\n```\n\nor\n\n```bash\nkysely migrate \u003ccommand\u003e\n```\n\n\u003e [!NOTE]\n\u003e `rollback` without `--all` flag is not supported, as [Kysely](https://kysely.dev)\ndoesn't keep track of \"migration batches\".\n\n\u003c/details\u003e\n\n#### Seed\n\n\u003cdetails\u003e\n\u003csummary\u003eThe \u003ccode\u003eseed\u003c/code\u003e module mirrors \u003ca href=\"https://knexjs.org\"\u003eKnex.js\u003c/a\u003e CLI's module of the same\nname.\u003c/summary\u003e\n\n```bash\nknex seed:\u003ccommand\u003e\n```\n\nCan now be called as either:\n\n```bash\nkysely seed:\u003ccommand\u003e\n```\n\nor\n\n```bash\nkysely seed \u003ccommand\u003e\n```\n\n\u003e [!NOTE]\n\u003e We also provide `kysely seed list`, which is not part of [Knex.js](https://knexjs.org)\nCLI.\n\n\u003c/details\u003e\n\n#### SQL\n\n\u003cdetails\u003e\n\u003csummary\u003eThe \u003ccode\u003esql\u003c/code\u003e module allows you to run SQL queries directly from the command line using the \u003ccode\u003ekysely\u003c/code\u003e instance.\u003c/summary\u003e\n\nSingle-query:\n\n```bash\nkysely sql \"select 1\"\n```\n\nor interactive mode:\n\n```bash\nkysely sql -f json\n\n✔ sqlite ❯\nselect 1;\n{\n  \"rows\": [\n    {\n      \"1\": 1\n    }\n  ]\n}\n\n❯ sqlite ❯\nexit\n```\n\n\u003c/details\u003e\n\n## Acknowledgements\n\n[acro5piano](https://github.com/acro5piano) who built [kysely-migration-cli](https://github.com/acro5piano/kysely-migration-cli)\nand inspired this project.\n\n[UnJS](https://unjs.io)'s amazing tools that help power this project.\n\n[Knex.js](https://knexjs.org) team for paving the way.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkysely-org%2Fkysely-ctl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkysely-org%2Fkysely-ctl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkysely-org%2Fkysely-ctl/lists"}