From e330e906889d00bc939db66c97ec0644ecbc2a08 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 675ac54d7..23fa8d2c7 100644 --- a/packages/prisma/schema.prisma +++ b/packages/prisma/schema.prisma @@ -117,6 +117,7 @@ model Document { DocumentMeta DocumentMeta? @relation(fields: [documentMetaId], references: [id], onDelete: Cascade) @@unique([documentDataId]) + @@unique([documentMetaId]) } enum DocumentDataType { @@ -134,10 +135,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 {