Am i supposed to add the drizzle folder to .gitignore?

I'm talking about the migrations and meta files. I don't need to commit those do I?
5 Replies
hachikuku
hachikuku3mo ago
you're supposed to ideally commit migrations since they're basically the history of the database and are applied sequentially to get on the current db state.
Need_Not
Need_NotOP3mo ago
Are they applied in order? When I apply them it just applies the file I put. I assumed it was the difference between current and last. If someone else is running it they might go from 3 -> 7 and they would simply generate their own migration which does that instead of taking all the steps
aleclarson
aleclarson3mo ago
The documentation says nothing about best practice here: https://orm.drizzle.team/docs/drizzle-kit-generate You should open an issue for clarification, so they know the docs are incomplete.
Drizzle ORM - generate
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
JustWayne
JustWayne3mo ago
Drizzle kit needs to know the previous shape of your models in order to create a migration that makes the appropriate changes. Look in one of the snapshot.json files that gets created, you can see how it stores the shape of every model for that snapshot. Then when you create the next migration, it compares that snapshot with the current state of your models from your TypeScript code. I check my drizzle folder into git, but I only commit changes to the drizzle/meta when a migration is ready to ship. If a migration isn't ready to ship, I throw away the drizzle/meta changes and I may or may not commit the generated SQL at that time if I want to track whats cooking.
✨✨✨
✨✨✨3mo ago
Don't put anything from the drizzle folder into gitignore. The migration files, the snapshots and the journal are all necessary to apply the changes to the DB. The migrations are typically applied in the production start script by calling migrate before starting the server with node. The migration history is stored in each DB, it decides which migrations will be applied. Push the migration changes along with the schema changes.

Did you find this page helpful?