Prisma `migrate dev` prompts for migration name when running after --create-only
See original GitHub issueSuppose you create your migration files using:
prisma migrate dev --create-only --preview-feature
Then when you run prisma migrate dev --preview-feature
to apply the changes (without changing the SQL), you are prompted for a migration name. Once entered, everything applies but you end up with a migration file that just drops and adds FK’s.
I assume this is because you’re expecting --create-only
to only be used as a precursor to manual sql changes being made to the generated SQL files but that’s not the case with me - it’s just easier to build into my flow and I also like to check the SQL before it’s applied.
If the SQL hasn’t changed, I wouldn’t expect to be prompted to enter a new migration name.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:32 (15 by maintainers)
Top Results From Across the Web
Prisma Migrate in development and production
Generates a new migration from any changes you made to the Prisma schema before running migrate dev; Applies all unapplied migrations to the...
Read more >Prisma Migrate | Database, Schema, SQL Migration Tool
Prisma Migrate is a database migration tool available via the Prisma CLI that integrates with Prisma schema for data modeling.
Read more >Adding Prisma Migrate to an existing project
Run the following command to create the first migration without applying it, in case you need ... $prisma migrate dev --name initial-migration --create-only....
Read more >Migration troubleshooting in development - Prisma
This guide describes how to resolve issues with Prisma Migrate in a development environment, which often involves resetting your database.
Read more >Prisma CLI Command Reference
Creates a new migration based on the changes in the schema but does not apply that migration. Run migrate dev to apply migration....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I can confirm this particular issue is now resolved on 2.18.0 🥳
I am no longer prompted for a second migration name and it creates the first one fine.
Thanks @tomhoule and @pimeys
@pantharshit00
Ok, I’m running 2 commands, not 3:
1:
npx prisma migrate dev --create-only --preview-feature
2:npx prisma migrate dev --preview-feature
In that order. First is to create the file, second is to apply it.
What happens?
Run (1) then it asks for a migration name, I enter
Init
. Migration is created as expected. Run (2) and it applies theInit_xxx
migration. It then immediately asks me for another migration name. If I enter a migration name here, I get a migration which just drops and then recreates the FK’s. Basically, it’s doing nothing. I think the issue stems from the fact that it shouldn’t be asking for a migration at this point. If I escape out of the process then the second migration file isn’t created but I don’t like doing this as the command should be allowed to complete.I’m on windows 10 with mysql server 8.0