Skip to content

Cannot migrate relational field from optional to required with @default(cuid()) #4716

@seanemmer

Description

@seanemmer

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug/2-confirmedBug has been reproduced and confirmed.kind/bugA reported bug.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions