Skip to content

Running prisma migrate dev --create-only actually applies previous (non-deployed) migrations #11184

@manassra

Description

@manassra

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

Suppose 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

  1. Modify your schema
  2. Run prisma migrate dev --create-only to create the migration file for the change
  3. Modify your schema again
  4. Run prisma migrate dev --create-only to 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions