Hey all, just a general question about prisma migr...
# orm-help
d
Hey all, just a general question about prisma migrations and seeding. When doing development, say I make a change to a model that requires making a change to my seed script due to the model change. I can run
prisma db push
to "push" the changes to the database without actually creating a new migration, but if I run
prisma db seed
, it doesn't reset the database in the same way that
prisma migrate reset
would do - it would just run the seed scripts twice, potentially duplicating data, etc. Is there a suggested workflow for prototyping seed changes without needing to either (a)
prisma migrate reset
or (b) drop all the records across all tables in the seed script?
r
@Danny 👋 Best way would be to check if data already exists and only insert it if it does.
d
@Ryan But I am trying to find a nice way to prototype changes to my seed script... It would be perfect if
prisma db seed
automatically resets the data and makes it as easy to prototype changes as
prisma db push
does.
Okay I think I figured out the best workflow. Found out that
prisma db push
will notice schema changes that are not possible to execute due to existing data that presumably originating from the (now outdated) seed so it prompts for a db reset. At that point I could make the changes to my seed file and try to re-run
prisma db seed
for prototyping. Still, my natural inclination would be that
prisma db seed
should be idempotent and reset the database for me (maybe with a
prisma db seed --no-reset
option).
r
Seed is not idempotent at the moment as it works on the current state of data in the database. You need to combine it with
prisma migrate reset
and to get clean data on inserts.
A feature request for this here would be great though 🙂