Closed henrikskog closed 8 months ago
Yeah I see your point. I guess I am a bit biased in how I have only used this command in combination with deleting my database, but I strongly agree with how deleting the database should never come as a surprise when running a script. What do you think about it now?
Now I add a new script instead:
"migrate-with-fixtures": "dotenv -e .env -- turbo run migrate -- latest --with-fixtures && cd packages/db && pnpm generate-types",
"migrate-with-fixtures-with-db-wipe": "dotenv -e .env -- turbo run migrate -- latest --with-fixtures --with-db-wipe && cd packages/db && pnpm generate-types",
Can't we just do
onConflict((eb) => eb.doNotihng()))
or whatever it is?
Alternatively, update the conflicting fields to take the new value?
Aaaa that's what that was for! Yeah we could do that. I removed all of that in https://github.com/dotkom/monoweb/pull/817 oops 😅
However, as this just adds a new script I don't think there is any harm in merging this?
Aaaa that's what that was for! Yeah we could do that. I removed all of that in #817 oops 😅
However, as this just adds a new script I don't think there is any harm in merging this?
I think I agree with @henrikhorluck I don't think running any fixtures should ever drop the entire database, even if it's just adding a new command.
If this is a problem you often come across, I think it's easier for you to just drop the database yourself with psql or your favorite database viewer
I'm happy to merge in the onConflict changes though!
Fair enough guys :( The problem is really actually solved by just adding the
.onConflict((conflict) => conflict.doNothing())
I'll create a new PR and close this
When running
migrate-with-fixtures
you want to run this on a clean slate database, or else you will get conflicts with existing data. This adds an option to the migrator to wipe the database as the first thing that happens, and changes themigrate-with-fixtures
script to use it.