Skip to content

[Introspection] No @default attribute when introspecting on PostgreSQL from Prisma V1 #1897

@pguilbault

Description

@pguilbault

Bug description

I am trying to migrate from Prisma1 to Prisma2.
When I introspect the database, default values are not generated in the output schema.

How to reproduce

Here is my database schema:

CREATE TABLE "default$default"."User"
(
    id character varying(25) COLLATE pg_catalog."default" NOT NULL,
    isActive boolean NOT NULL,
    CONSTRAINT "User_pkey" PRIMARY KEY (id)
)

Database schema has no DEFAULT constraint defined for the column isActive so it seems logical that there is no @default attribute in the datamodel after the introspection (Prisma2).

However, it works fine with the Prisma1 introspection where the generated datamodel has the @default attributes.

The introspected schema:

model User {
  id                        String                      @id
  isActive                  Boolean
}

Expected behavior

I was expecting the following Prisma2 schema:

model User {
  id                        String                      @id                      @default(cuid())
  isActive                  Boolean                      @default(true)
}

Same behaviour with the @createdAt and @updatedAt directives.

Where are defined (or stored) these constraints in the underlying database when using Prisma1 ?

Environment & setup

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions