prisma: `Gist` index not supported on prisma schema (Exclusion constraint)
Bug description
Hello
I’m introspecting my database and this is the schema that is being generated when I use the prisma cli and run npx prisma db pull.
model appointment {
account_id String @default(dbgenerated("(current_setting('app.account'::text))::uuid")) @db.Uuid
id String @default(dbgenerated("gen_random_uuid()")) @db.Uuid
date Unsupported("tstzrange")
patient_id String @db.Uuid
is_paid Boolean @default(false)
is_active Boolean @default(true)
created_at DateTime @default(now()) @db.Timestamptz(6)
patient patient @relation(fields: [account_id, patient_id], references: [account_id, id], onDelete: NoAction, onUpdate: NoAction, map: "FK_Appointment_patient_id__Patient_id")
account account @relation(fields: [account_id], references: [id], onDelete: NoAction, onUpdate: NoAction)
@@id([account_id, id], map: "PK_Appointment_account_id_id")
@@index([account_id, date], map: "appointment_account_id_date_excl", type: Gist)
}
I get the following error once I try to generate the client by running npx prisma generate.
This is the error.
Error: Schema validation error - Error (query-engine-node-api library)
Error code: P1012
error: Error parsing attribute "@@index": The Gist index field type `Uuid` has no default operator class.
--> schema.prisma:54
|
53 | @@id([account_id, id], map: "PK_Appointment_account_id_id")
54 | @@index([account_id, date], map: "appointment_account_id_date_excl", type: Gist)
|
Validation Error Count: 1
[Context: getDmmf]
I thought Gist indexes where supported as stated on https://www.prisma.io/docs/concepts/components/prisma-schema/indexes#index-configuration
How to reproduce
Try to generate the prisma client based from this schema, use the cli npx prisma generate.
model appointment {
account_id String @default(dbgenerated("(current_setting('app.account'::text))::uuid")) @db.Uuid
id String @default(dbgenerated("gen_random_uuid()")) @db.Uuid
date Unsupported("tstzrange")
patient_id String @db.Uuid
is_paid Boolean @default(false)
is_active Boolean @default(true)
created_at DateTime @default(now()) @db.Timestamptz(6)
patient patient @relation(fields: [account_id, patient_id], references: [account_id, id], onDelete: NoAction, onUpdate: NoAction, map: "FK_Appointment_patient_id__Patient_id")
account account @relation(fields: [account_id], references: [id], onDelete: NoAction, onUpdate: NoAction)
@@id([account_id, id], map: "PK_Appointment_account_id_id")
@@index([account_id, date], map: "appointment_account_id_date_excl", type: Gist)
}
Expected behavior
The prisma client is generated with no errors.
Prisma information
model appointment {
account_id String @default(dbgenerated("(current_setting('app.account'::text))::uuid")) @db.Uuid
id String @default(dbgenerated("gen_random_uuid()")) @db.Uuid
date Unsupported("tstzrange")
patient_id String @db.Uuid
is_paid Boolean @default(false)
is_active Boolean @default(true)
created_at DateTime @default(now()) @db.Timestamptz(6)
patient patient @relation(fields: [account_id, patient_id], references: [account_id, id], onDelete: NoAction, onUpdate: NoAction, map: "FK_Appointment_patient_id__Patient_id")
account account @relation(fields: [account_id], references: [id], onDelete: NoAction, onUpdate: NoAction)
@@id([account_id, id], map: "PK_Appointment_account_id_id")
@@index([account_id, date], map: "appointment_account_id_date_excl", type: Gist)
}
Environment & setup
- macOS
- Postgres 14
- Prisma CLI Version : 4.3.1
- Node 16.15.1
Prisma Version
4.3.1
About this issue
- Original URL
- State: open
- Created 4 years ago
- Comments: 15 (7 by maintainers)
Internal: Next step is to try to reproduce locally what @gmwill934 is seeing, and then figure out what is going on with that ops class.
Absolutely @janpio
AccountPatientAppointmentYes, @janpio I do have the
btree_gistextension activatedWe should be better in introspecting these then @gmwill934. Can you share the SQL of the
appointmenttable (and maybe the ones it has relations with, although we can certainly clean that out if not)? Thanks.Hi @gmwill934, could you please share the rest of your schema? We see that the
appointmentmodel references thepatientandaccountmodels as well.These are the operator classes of GiST we currently support for Postgres. We currently provide an escape hatch to use a custom operator class in GiST and Gin indexes, via
ops:Besides, I see the
datefield mentioned in the@@indexis using thetstzrangeextension, which is not supported by Prisma (I would have linked you to https://github.com/prisma/prisma/issues/3287, but I see you have already found that issue on your own ☺️).