From a9b63edc0f0fa5e04675a4e2e829b21a2a7caa01 Mon Sep 17 00:00:00 2001 From: adarsshkg-codebank Date: Tue, 10 Mar 2026 06:59:23 +0530 Subject: [PATCH] feat:adding template and template_fields schema --- prisma/schema.prisma | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 45e86ed..e8307e4 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -18,6 +18,7 @@ model User { accounts Account[] formResponses FormResponse[] sessions Session[] + templates Template[] @@map("user") } @@ -99,6 +100,40 @@ model FormFields { @@map("form_fields") } +model Template { + id String @id @default(uuid()) + title String + description String? + ownerId String? + isBuiltIn Boolean @default(false) + sourceTemplateId String? + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + owner User? @relation(fields: [ownerId], references: [id], onDelete: Cascade) + templateFields TemplateField[] + + @@map("template") +} + +model TemplateField { + id String @id @default(uuid()) + fieldName String + label String? + fieldValueType String + fieldType String + validation Json? + options Json? + prevFieldId String? + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + templateId String + template Template @relation(fields: [templateId], references: [id], onDelete: Cascade) + + @@index([templateId]) + @@index([templateId, prevFieldId]) + @@map("template_fields") +} + model FormResponse { id String @id @default(uuid()) formId String