lukeed / ley

(WIP) Driver-agnostic database migrations
MIT License
260 stars 14 forks source link

Flag to generate TypeScript migration files #34

Open karlhorky opened 1 year ago

karlhorky commented 1 year ago

Hi @lukeed 👋 Hope you're well!

Since there is the ability to generate .mjs (ES Modules) migration files using the ley new --esm flag, would be great to also get ability to generate TypeScript migrations using a flag, eg:

$ ley new todos --ts
#=> migrations/003-todos.ts

As an additional detail, this feature could also import the types for the library being used (although I can understand if Ley does not want to maintain these as a library). Eg. for Postgres.js, it could be:

import { Sql } from 'postgres'

export async function up(client: Sql) {}

export async function down(client: Sql) {}

Since new users may forget to also configure tsm, it may be helpful to also improve the error message when TypeScript causes ley migrate commands to fail: