feat: add templates for transactional emails (#103)
* add template migration & router * template CRUD * templated transactional emails API * zod schema fix & rearranging template columns
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "Template" (
|
||||
"id" TEXT NOT NULL,
|
||||
"name" TEXT NOT NULL,
|
||||
"teamId" INTEGER NOT NULL,
|
||||
"subject" TEXT NOT NULL,
|
||||
"html" TEXT,
|
||||
"content" TEXT,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "Template_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "Template_createdAt_idx" ON "Template"("createdAt" DESC);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Template" ADD CONSTRAINT "Template_teamId_fkey" FOREIGN KEY ("teamId") REFERENCES "Team"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
@@ -101,6 +101,7 @@ model Team {
|
||||
emails Email[]
|
||||
contactBooks ContactBook[]
|
||||
campaigns Campaign[]
|
||||
templates Template[]
|
||||
dailyEmailUsages DailyEmailUsage[]
|
||||
}
|
||||
|
||||
@@ -286,6 +287,20 @@ model Campaign {
|
||||
@@index([createdAt(sort: Desc)])
|
||||
}
|
||||
|
||||
model Template {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
teamId Int
|
||||
subject String
|
||||
html String?
|
||||
content String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
team Team @relation(fields: [teamId], references: [id], onDelete: Cascade)
|
||||
@@index([createdAt(sort: Desc)])
|
||||
}
|
||||
|
||||
enum EmailUsageType {
|
||||
TRANSACTIONAL
|
||||
MARKETING
|
||||
|
Reference in New Issue
Block a user