Hey everyone! I’m wondering if you can help me, I ...
# orm-help
s
Hey everyone! I’m wondering if you can help me, I made a number of changes to my schema and actually migrated from an older version of Prisma to 2.30.3 (yes still old, but better than it was!). I’m getting the error
Could not find the migration file at /app/prisma/migrations/dev/migration.sql. Please delete the directory or restore the migration file.
Is there a programmatic way to handle resolving this error? The command that I’m running to get me to this point is:
npx prisma migrate dev -n dev
which connects to a postgres container running in the cluster. I’m running this at a few sites where some of them have fresh databases so this error won’t happen there, but those with existing databases have this error. A partial solution I came up with is to run
npx prisma reset -f
which is not ideal because it resets everything but has the further complication that I'd need to somehow run the migrate command and then based on the status code run this reset command which isn't the best solution.
t
Hi Stephen! There is no command to automatically delete empty migration directories (where a
migration.sql
is missing). Is there anything preventing from running
rm -r /app/prisma/migrations/dev
?
it's purely a problem with the migrations files, you don't need to touch the database
It could also be that migrate is looking for the migrations in the wrong place. I think it's hardcoded to the
migrations
directory next to your
schema.prisma
s
Hi Tom! Thanks for your suggestion. I tried deleting the
/app/prisma/migrations/dev
folder when it detects it and then I run
prisma migrate dev -n dev
. I get an error:
Error: Prisma Migrate has detected that the environment is non-interactive which is not supported
prisma migrate dev
is an interactive command designed to create new migrations and evolve the database in development. Is there a better command I should be running once I delete the migrations dev folder?
t
We have issues about this: https://github.com/prisma/prisma/issues/7113 and https://github.com/prisma/prisma/issues/9943 at least. Short answer is: using migrate dev from scripts is not supported. We're working on new different commands we're going to release in preview soon to address these use cases.
❤️ 1
s
Awesome, thanks so much for the heads up!