question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Prisma `migrate dev` prompts for migration name when running after --create-only

See original GitHub issue

Suppose 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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:32 (15 by maintainers)

github_iconTop GitHub Comments

5reactions
webnoobcommented, Mar 11, 2021

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

3reactions
webnoobcommented, Feb 1, 2021

@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 the Init_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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found