Migrate: enum default is added to the migration README every time

Created on 22 Jun 2020  路  3Comments  路  Source: prisma/migrate

Bug description

If you have enum defaults in your schema, any subsequent migrations will add an alter table statement in the "database steps" section of the migration readme, despite those steps not existing in steps.json.

How to reproduce

1) Create the following datamodel:

enum WorkerRole {
  ADMIN
  OWNER
}

model Worker {
  role WorkerRole @default(ADMIN)
}

2) Run prisma migrate save and up

3) Add a new field to Worker (or any other model in the schema):

model Worker {
  role WorkerRole @default(ADMIN)
  test String
}

4) Look at the migration files - the README contains the following database step, despite that already existing in the DB, and no corresponding step existing in steps.json:

ALTER TABLE "default$default"."Worker" ALTER COLUMN "role" SET DEFAULT E'ADMIN';

Expected behavior

Avoid these steps appearing in the README when they aren't actually being executed.

Environment & setup

  • OS: Mac OS
  • Database: PostgreSQL
  • Prisma version: 2.0.1
  • Node.js version: 14.2.0
bu2-confirmed kinbug

All 3 comments

Looks like a bug in our diffing logic, thanks for reporting this!

I can't reproduce this issue locally. Can you confirm it still happens for you with a fresh database?

Seems to be fine as of v2.2! Thanks

Was this page helpful?
0 / 5 - 0 ratings