Skip to content

migrate dev --create-only with empty schema but existing database schema detects drift and warns about deleting all data #6579

@janpio

Description

@janpio

Bug description

  • No models in schema.prisma
  • 1 table in database schema
  • Running migrate dev --create-only gives following output:
PS C:\Users\piotr\Documents\serverless-prisma\demo> npx prisma migrate dev --create-only
Environment variables loaded from .env
Prisma schema loaded from prisma\schema.prisma
Datasource "db": PostgreSQL database "tests", schema "public" at "localhost:5432"

√ Drift detected: Your database schema is not in sync with your migration history.

We need to reset the PostgreSQL database "tests" at "localhost:5432".
Do you want to continue? All data will be lost. ... yes

√ Name of migration ... init
Prisma Migrate created the following migration without applying it 20210414181550_init

You can now edit it and apply it by running prisma migrate dev.

--create-only needing to reset my database, and supposedly even doing that, was unexpected.

Expected behavior

No changes on data or warnings that indicate that when using --create-only.

Prisma information

PS C:\Users\piotr\Documents\serverless-prisma\demo> npx prisma -v
Environment variables loaded from .env
prisma               : 2.21.1
@prisma/client       : 2.21.1
Current platform     : windows
Query Engine         : query-engine e421996c87d5f3c8f7eeadd502d4ad402c89464d (at node_modules\@prisma\engines\query-engine-windows.exe)
Migration Engine     : migration-engine-cli e421996c87d5f3c8f7eeadd502d4ad402c89464d (at node_modules\@prisma\engines\migration-engine-windows.exe)
Introspection Engine : introspection-core e421996c87d5f3c8f7eeadd502d4ad402c89464d (at node_modules\@prisma\engines\introspection-engine-windows.exe)
Format Binary        : prisma-fmt e421996c87d5f3c8f7eeadd502d4ad402c89464d (at node_modules\@prisma\engines\prisma-fmt-windows.exe)
Default Engines Hash : e421996c87d5f3c8f7eeadd502d4ad402c89464d
Studio               : 0.371.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