-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Running prisma migrate dev --create-only actually applies previous (non-deployed) migrations #11184
Copy link
Copy link
Open
Labels
bug/2-confirmedBug has been reproduced and confirmed.Bug has been reproduced and confirmed.kind/bugA reported bug.A reported bug.tech/enginesIssue for tech Engines.Issue for tech Engines.topic: prisma migrate dev --create-onlyCLI: prisma migrate dev --create-onlyCLI: prisma migrate dev --create-only
Description
Bug description
Imagine a situation where you are iterating on your schema, and using the following command to create the migration files without actually applying any of them.
prisma migrate dev --create-onlySuppose you initially run it the first time where you want to add migration A. When you run it a second time to add migration B, you get the following output from the same command:
The following migration(s) have been applied:
migrations/
└─ 20220114234207_add_A/
This is problematic as the user may not have intended to actually apply migration A
How to reproduce
- Modify your schema
- Run
prisma migrate dev --create-onlyto create the migration file for the change - Modify your schema again
- Run
prisma migrate dev --create-onlyto create the new migration file for the second change
Expected behavior
Either:
- Option 1: Only create the migration files without applying any to the database
- Option 2: if option 1 is not feasible, add a confirmation prompt to inform the user that prior pending migrations will also be run.
Prisma information
In my test, each run of the prisma migrate dev --create-only command was adding a new column to existing tables in my schema.
Environment & setup
- OS:Mac OS,
- Database: PostgreSQL
- Node.js version: v16.13.0
Prisma Version
prisma : 2.30.2
@prisma/client : 2.30.2
Current platform : darwin
Query Engine (Binary) : query-engine b8c35d44de987a9691890b3ddf3e2e7effb9bf20 (at node_modules/@prisma/engines/query-engine-darwin)
Migration Engine : migration-engine-cli b8c35d44de987a9691890b3ddf3e2e7effb9bf20 (at node_modules/@prisma/engines/migration-engine-darwin)
Introspection Engine : introspection-core b8c35d44de987a9691890b3ddf3e2e7effb9bf20 (at node_modules/@prisma/engines/introspection-engine-darwin)
Format Binary : prisma-fmt b8c35d44de987a9691890b3ddf3e2e7effb9bf20 (at node_modules/@prisma/engines/prisma-fmt-darwin)
Default Engines Hash : b8c35d44de987a9691890b3ddf3e2e7effb9bf20
Studio : 0.422.0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bug/2-confirmedBug has been reproduced and confirmed.Bug has been reproduced and confirmed.kind/bugA reported bug.A reported bug.tech/enginesIssue for tech Engines.Issue for tech Engines.topic: prisma migrate dev --create-onlyCLI: prisma migrate dev --create-onlyCLI: prisma migrate dev --create-only