Skip to content

int8 literal @default renders as DEFAULT '0'::int8, so db migrate fails its own schema verification #30174

Description

@reinhaaard13

Package and version

@prisma/orm-postgres 8.0.0-rc.8, prisma CLI 8.0.0-rc.12

What happened?

A literal @default on an int8 column makes prisma db migrate reject the migration it has just executed.

contract emit records the default as a numeric literal, but the DDL renderer writes it as a quoted cast, and the post-apply schema verifier then compares the two and fails.

contract.json:

"v": {
  "codecId": "pg/int8number@1",
  "default": { "kind": "literal", "value": 0 },
  "nativeType": "int8",
  "nullable": false
}

Generated DDL — note int4 on the next line is correct, int8 is not:

"v" int8 DEFAULT '0'::int8 NOT NULL,
"w" int4 DEFAULT 0         NOT NULL,

db migrate result:

MIGRATION.RUNNER_FAILED  (runnerErrorCode: MIGRATION.SCHEMA_VERIFY_FAILED)
"The resulting database schema does not satisfy the destination contract."

issue: path ["database","public","ps","column:v","default"]
  expected { "kind": "literal", "value": 0 }
  actual   { "kind": "literal", "value": "0", "raw": "'0'::bigint" }

The migration rolls back cleanly, so the failure is loud rather than silent — but the stage cannot be applied at all.

What did you expect to happen?

db migrate to apply and verify, with the int8 default rendered as an unquoted literal the way int4 already is — or the verifier to treat '0'::int8 and the numeric literal 0 as equal.

Minimal reproduction

Whole contract:

model P {
  id String       @id @default(uuid())
  v  BigIntNumber @default(0)
  w  Int          @default(0)
  @@map("ps")
}
prisma contract emit          # ok
prisma migration plan --from @empty --name t   # ok — DDL contains DEFAULT '0'::int8
prisma db migrate             # fails: MIGRATION.SCHEMA_VERIFY_FAILED

Findings from narrowing it down:

  • BigInt @default(0) produces identical DDL, so this is the int8 codec family rather than BigIntNumber specifically.
  • Int @default(0) renders DEFAULT 0 unquoted and verifies fine, so the two paths only disagree for int8.
  • Removing the default is the only workaround I found; no int8 spelling avoids it.
  • The value is irrelevant — @default(1) renders DEFAULT '1'::int8 the same way.

Environment

  • macOS, arm64
  • Node.js 24
  • PostgreSQL 17 (official Docker image)
  • pnpm workspace, prisma.config.ts via definePrismaConfig + defineConfig from @prisma/orm-postgres/config

Additional context

Impact in practice: this blocks any stage containing an int8 column with a default. In a whole-rupiah money model (all amounts int8) it meant stripping @default(0) from 22 columns before a 123-model schema could be applied — invoice/credit-note/refund totals and a NumberSequence counter. The consequence is that no money column defaults to zero any more and every writer must supply a value.

Separately, and possibly worth its own issue: prisma feedback "<anything>" currently fails with

FEEDBACK.SEND_FAILED — The feedback service responded with HTTP 400
(meta must be an object with string values.)

for any message, including a one-word one, which is why this is a GitHub issue rather than CLI feedback. references/feedback.md in the bundled agent skills also points bug reports at https://github.com/prisma/prisma-next/issues/new/choose, which is archived with issues disabled.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions