PrismaP
Prisma8mo ago
9 replies
fixed

Enum failed to apply cleanly to database

I'm having issues creating new migrations for my cockroachdb prisma layout.

I have one migration named 20240119154759_tag_naming_update_grant_redef with the contents:
ALTER TYPE "ExampleType" ADD VALUE 'GRANT';


and
20240129071034_split_renaming_migrations with the contents:
UPDATE "Example"
SET "type" = 'GRANT'
WHERE "type" = 'CREATE';

ALTER TYPE "ExampleType" DROP VALUE 'CREATE';


I get the error running (npx prisma migrate dev --name unrelated_migration --create-only --schema prisma/cockroach/cockroach.prisma):
Error: P3006

Migration `20240129071034_split_renaming_migrations` failed to apply cleanly to the shadow database.
Error:
ERROR: invalid input value for enum ExampleType: "GRANT"
   0: schema_core::state::DevDiagnostic
             at schema-engine/core/src/state.rs:281
only when running migrations against the shadow db; running npx prisma migrate reset fully applies correctly

Not sure if this is a regression with how the migration stuff works but it happened between the 5.22.0 -> 6.0.0 update

The migration succeeds in 5.22.0

They're in different files because of some surrounding bits unrelated to that specific piece of the migration; however this migration setup itself should work.

The initial table in the init migration looks like this which is timestamped before the prior 2:
CREATE TABLE "Example" (
    "type" "ExampleType" NOT NULL,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "exampleId" STRING NOT NULL,

    CONSTRAINT "Example_pkey" PRIMARY KEY ("exampleId")
);


this is my prisma schema config:
generator client {
  provider = "prisma-client-js"
}

generator json {
  provider = "prisma-json-types-generator"
}

datasource db {
  provider = "cockroachdb"
  url      = env("COCKROACH_DB_URL")
}


Looking forward for any help, I can make a github issue with this outlined as well, I didn't notice anything similar
Was this page helpful?