From 826a901c109d88f779852aa903496e4b16292401 Mon Sep 17 00:00:00 2001 From: Ephraim Atta-Duncan Date: Wed, 20 Sep 2023 12:54:24 +0000 Subject: [PATCH] fix: document meta relation with document --- .../migration.sql | 8 ++++++++ packages/prisma/schema.prisma | 5 +++-- 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 packages/prisma/migrations/20230920124941_fix_documentmeta_relation/migration.sql diff --git a/packages/prisma/migrations/20230920124941_fix_documentmeta_relation/migration.sql b/packages/prisma/migrations/20230920124941_fix_documentmeta_relation/migration.sql new file mode 100644 index 000000000..69b4591c5 --- /dev/null +++ b/packages/prisma/migrations/20230920124941_fix_documentmeta_relation/migration.sql @@ -0,0 +1,8 @@ +/* + Warnings: + + - A unique constraint covering the columns `[documentMetaId]` on the table `Document` will be added. If there are existing duplicate values, this will fail. + +*/ +-- CreateIndex +CREATE UNIQUE INDEX "Document_documentMetaId_key" ON "Document"("documentMetaId"); diff --git a/packages/prisma/schema.prisma b/packages/prisma/schema.prisma index b58baac8a..56c29a64e 100644 --- a/packages/prisma/schema.prisma +++ b/packages/prisma/schema.prisma @@ -118,6 +118,7 @@ model Document { DocumentMeta DocumentMeta? @relation(fields: [documentMetaId], references: [id], onDelete: Cascade) @@unique([documentDataId]) + @@unique([documentMetaId]) } enum DocumentDataType { @@ -135,10 +136,10 @@ model DocumentData { } model DocumentMeta { - id String @id @default(cuid()) + id String @id @default(cuid()) customEmailSubject String? customEmailBody String? - Document Document[] + Document Document? } enum ReadStatus {