Migrate: Migration fails after changing ENUM

Created on 25 Feb 2020  路  5Comments  路  Source: prisma/migrate

After updating to preview 22 and migrating the DB, everything worked fine. But then when I changed one enum it started failing.
Migrations now contain TestStatus_new which I guess is used to migrate the enum from TestStatus. But it contains it even though I deleted all tables from the DB and migrations too

 ERROR  Oops, an unexpected error occured!
Failure during a migration command: Connector error. (error: Error queryin
g the database: Error querying the database: Error querying the database: 
db error: ERROR: type "TestStatus_new" already exists)

UPDATE: Deleting the whole DB helps

bu2-confirmed enginemigration engine kinbug tecengines

Most helpful comment

I can confirm this bug. I would guess that we are somehow using the old migrate logic even after updating the enum implementation to use native database types.

Steps to reproduce:

  1. Bootstrap the following datamodel:
    ```prisma
    datasource db {
    provider = "postgresql"
    url = env("DATABASE_URL")
    }
generator client {
  provider = "prisma-client-js"
}

enum Permissions {
  ADMIN
  USER 
}

model User {
  id String @id @default(cuid())
  name String
  permission Permissions[]
}
```

  1. Add some data to the application via studio: prisma2 studio --experimental. Make sure at least one row uses the USER enum
  2. Change it to the following datamodel and perform a migration:
    ```prisma
    datasource db {
    provider = "postgresql"
    url = env("DATABASE_URL")
    }
generator client {
  provider = "prisma-client-js"
}

enum Permissions {
  ADMIN
  ASSOCIATE 
}

model User {
  id String @id @default(cuid())
  name String
  permission Permissions[]
}

```

It should throw the following Rust panic:
image

Version: [email protected], binary version: 687716d3305368e3f586f8957de2037fd8a50f8f

All 5 comments

I can confirm this bug. I would guess that we are somehow using the old migrate logic even after updating the enum implementation to use native database types.

Steps to reproduce:

  1. Bootstrap the following datamodel:
    ```prisma
    datasource db {
    provider = "postgresql"
    url = env("DATABASE_URL")
    }
generator client {
  provider = "prisma-client-js"
}

enum Permissions {
  ADMIN
  USER 
}

model User {
  id String @id @default(cuid())
  name String
  permission Permissions[]
}
```

  1. Add some data to the application via studio: prisma2 studio --experimental. Make sure at least one row uses the USER enum
  2. Change it to the following datamodel and perform a migration:
    ```prisma
    datasource db {
    provider = "postgresql"
    url = env("DATABASE_URL")
    }
generator client {
  provider = "prisma-client-js"
}

enum Permissions {
  ADMIN
  ASSOCIATE 
}

model User {
  id String @id @default(cuid())
  name String
  permission Permissions[]
}

```

It should throw the following Rust panic:
image

Version: [email protected], binary version: 687716d3305368e3f586f8957de2037fd8a50f8f

Is there a workaround for this?

Can someone suggests some fix for this problem? instead of deleting the whole DB... (but yeah delete the whole DB works for me)

@shixian-hf run DROP SCHEMA public CASCADE

Duplicate of #414

Was this page helpful?
0 / 5 - 0 ratings