You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ticket_email_sourceId_key is a partial unique index, created in raw SQL on #170's branch:
CREATEUNIQUE INDEX "Ticket_email_sourceId_key"
ON"Ticket"("sourceId")
WHERE"source"='EMAIL'AND"sourceId"IS NOT NULL;
Prisma's schema language cannot express a WHERE clause on @@unique. So the index exists in the database and in the migration history, but has no representation in schema.prisma.
The failure mode
prisma migrate dev compares the schema against the database, sees an index it cannot account for, and reports drift. The suggested resolution is typically to drop it. Someone tidying up a drift warning, in good faith, removes the constraint that stops Postmark retries creating duplicate tickets — and nothing fails, because the guard it backs is a belt-and-braces read that usually catches the retry first.
Silent loss of a correctness guarantee, triggered by following the tool's advice.
What to do
Cheapest useful step is a comment in schema.prisma on the Ticket model, naming the index, saying it is intentionally raw-SQL-only, why Prisma cannot express it, and what breaks if it is dropped. A future reader hitting the drift warning then has the context at the point of decision.
Whether a CI check should assert the index still exists, so its removal fails loudly instead of silently. A single pg_indexes query in a migration test would do it.
Documenting the same trap in whatever contributing/migrations guide exists, since the next partial index will hit it too.
Related: #169 proposes more partial unique indexes for the other inbound doors, which would multiply this.
Ticket_email_sourceId_keyis a partial unique index, created in raw SQL on #170's branch:Prisma's schema language cannot express a
WHEREclause on@@unique. So the index exists in the database and in the migration history, but has no representation inschema.prisma.The failure mode
prisma migrate devcompares the schema against the database, sees an index it cannot account for, and reports drift. The suggested resolution is typically to drop it. Someone tidying up a drift warning, in good faith, removes the constraint that stops Postmark retries creating duplicate tickets — and nothing fails, because the guard it backs is a belt-and-braces read that usually catches the retry first.Silent loss of a correctness guarantee, triggered by following the tool's advice.
What to do
Cheapest useful step is a comment in
schema.prismaon theTicketmodel, naming the index, saying it is intentionally raw-SQL-only, why Prisma cannot express it, and what breaks if it is dropped. A future reader hitting the drift warning then has the context at the point of decision.Worth considering alongside:
Message(ticketId, responseKey)unique index on fix(ai): answer each ticket once, and stop showing reporters internal ticket IDs #170's branch is expressible in Prisma, so it is likely fine — worth confirming rather than assuming.pg_indexesquery in a migration test would do it.Related: #169 proposes more partial unique indexes for the other inbound doors, which would multiply this.