can anyone help me i have a problem with these migrations its always changing the tables that i didn
4 Replies
Hello, @Starko00! Could you describe your migration workflow? Do you use the
drizzle-kit push:pg
command?yup
bunx drizzle-kit generate:pg && bunx drizzle-kit push:pg
this is a combo comand i use to do it every time
i managed to fix a few of them and by inspectin the psql thats generated i can see that its always dropping all foreign keys and using then making them again -> this is not that of a problem as i guess it needs to do it if its gonna drop a table that has ground braking changes, but for other things like time stamps and numerics its ludarics, its actualy writing the same code over and over again
@solo
One minute
@Starko00 you have to change your migration workflow, because
drizzle-kit generate:pg
and drizzle-kit push:pg
commands are used for different approaches.
1. drizzle-kit generate:pg
This command generates SQL migration files representing changes needed to be applied to your schemas in database. To apply these migrations you have to use migrate
function. For example, if you use pg
driver you can import this function like this:
https://orm.drizzle.team/docs/migrations - docs
2. drizzle-kit push:pg
This command lets you push your schema changes directly to the database without generating any migrations files and does not require their use. Designed for rapid prototyping and experimentation. It is good for situations where you need to quickly test new schema designs or changes in a local development environment, allowing for fast iterations without the overhead of managing migration files.
https://orm.drizzle.team/kit-docs/overview#prototyping-with-db-push - docs
So you shouldn't use them together in your workflow. Try to generate migrations and then apply them using migrate
function.Drizzle ORM - next gen TypeScript ORM
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
Drizzle ORM - next gen TypeScript ORM
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.