prisma: Cannot migrate relational field from optional to required with @default(cuid())

Database: PostgreSQL (Digital Ocean)

Unable to convert an optional field to a required field:

model Dentist {
  id         String     @default(cuid()) @id
  name       String
  account    Account?
}

migrate to

model Dentist {
  id         String     @default(cuid()) @id
  name       String
  account    Account
}

Lift gives me the following prompt:

You are about to alter the column `account` on the `Dentist` table, which still contains 3 non-null values. The data in that column will be lost.

After confirming that this is ok (y), lift attempts to run and throws the following error:

thread 'tokio-runtime-worker-1' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:378:21

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 18 (11 by maintainers)

Most upvoted comments

This is still a problem with the latest version:

Environment variables loaded from ./prisma/.env
@prisma/cli          : 2.0.0-alpha.1299
Current platform     : debian-openssl-1.1.x
Query Engine         : query-engine d88852ac341cdf3c7379a08fa1ebc5c444a4aa67 (at /home/harshit/code/reproductions/issue-migrate_236/node_modules/@prisma/cli/query-engine-debian-openssl-1.1.x)
Migration Engine     : migration-engine-cli d88852ac341cdf3c7379a08fa1ebc5c444a4aa67 (at /home/harshit/code/reproductions/issue-migrate_236/node_modules/@prisma/cli/migration-engine-debian-openssl-1.1.x)
Introspection Engine : introspection-core d88852ac341cdf3c7379a08fa1ebc5c444a4aa67 (at /home/harshit/code/reproductions/issue-migrate_236/node_modules/@prisma/cli/introspection-engine-debian-openssl-1.1.x)
Format Binary        : prisma-fmt d88852ac341cdf3c7379a08fa1ebc5c444a4aa67 (at /home/harshit/code/reproductions/issue-migrate_236/node_modules/@prisma/cli/prisma-fmt-debian-openssl-1.1.x)

image