drizzle-team / drizzle-kit-mirror

Docs and issues repository for drizzle-kit
287 stars 16 forks source link

How can I always generate a single migration file, with `drizzle-kit`? #465

Open curiosbasant opened 3 weeks ago

curiosbasant commented 3 weeks ago

I've got a use case where, instead of using drizzle-kit push to directly update the database,. I instead want to generate a sql file from the schema and store that in the migrations folder.

So in my case, I always want to have a single source of truth for the schema in a SQL file.

I want to do it like this way, because I will then create more migration files on my own for other SQL statements that drizzle doesn't support yet. i.e. postgres policies, postgres functions, etc.

Vorelli commented 3 weeks ago

Do you expect your schema to ever change? Then you'll need to deal with multiple migration files unless you're deleting your data every schema change. You can pass the --custom argument to drizzle-kit in order to do your own manual migrations which will get their own file.

curiosbasant commented 3 weeks ago

Yes, my schema would change. But I always want to have a single migration file (which I would apply manually) that gets overridden with my drizzle schema each time I run a command.

Hopefully, that makes sense.