kysely-org / kysely-ctl

Command-line tool for Kysely
MIT License
65 stars 2 forks source link

JS Migrations Support #74

Closed felixguendling closed 1 month ago

felixguendling commented 1 month ago

Hello! :wave: Thank you for this project!

We're currently writing migrations in JS (no translation needed to use it in the SvelteKit server hook).

By default, kysely-ctl skips JS files: WARN Ignoring 2024-07-01.js - not a TS file.

By removing these lines, I could make it work:

https://github.com/kysely-org/kysely-ctl/blob/230798d8c2256d62e075d7bab621c6734d48b5ef/src/kysely/ts-file-migration-provider.mts#L27-L30

Would it be possible to relax this requirement, so TS and JS are both supported?

igalklebanov commented 1 month ago

Hey 👋

Thanks for raising this!

This project doesn't require any build step of TypeScript migration files before running commands. They just work at runtime, like in bun and deno.

We're currently writing migrations in JS (no translation needed to use it in the SvelteKit server hook).

Do you plan on running migrations from kysely-ctl and SvelteKit server separately?

Would it be possible to relax this requirement, so TS and JS are both supported?

I'm leaning towards an allowJS config option for migrations, off by default (trying to be TypeScript-first here).

felixguendling commented 1 month ago

We want to use kysely-ctl in a script that resets the database to a specific state for end-to-end tests. So we delete everything (drop the database and recreate it), run the migrations from scratch and then add testing data.

A allowJS flag in the configuration sounds like a great idea! 🥳

igalklebanov commented 1 month ago

Released in https://github.com/kysely-org/kysely-ctl/releases/tag/v0.9.0.

felixguendling commented 1 month ago

Thank you very much! It works and we switched from our ugly hack to the new version :-)