Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to sync schema #1

Open
ai opened this issue Aug 24, 2024 · 1 comment
Open

How to sync schema #1

ai opened this issue Aug 24, 2024 · 1 comment

Comments

@ai
Copy link

ai commented Aug 24, 2024

The Kysely officially recommended workflow is to auto-generate schema from DB (after running migrations).

What is recommended solution if I am using pglite during the development?

@dnlsandiego
Copy link
Owner

dnlsandiego commented Sep 2, 2024

I just implemented a CLI for generating types based on Kysely migrations or an existing PGlite database that's been persisted on disk. Usage would be:

npx kysely-pglite ./src/db/migrations --outFile ./src/db/schema.ts

It's mostly a wrapper around kysely-codegen, using its internal codegen directly. The CLI accepts the same options/flags as kysely-codegen. Currently it expects migration files to export up and down functions, same pattern as postgresql-migration-example.

It also has a --watch option, it will watch the migrations and regenerate the types when a migration file changes/deleted/added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants