-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement data logic and functionality
- Loading branch information
Showing
31 changed files
with
1,571 additions
and
11,479 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
-- CreateEnum | ||
CREATE TYPE "EmailAddressType" AS ENUM ('EMAIL_ADDRESS', 'EMAIL_ID', 'USER_ID'); | ||
|
||
-- CreateTable | ||
CREATE TABLE "EmailTemplate" ( | ||
"id" UUID NOT NULL DEFAULT gen_random_uuid(), | ||
"content" TEXT NOT NULL, | ||
"verifyReplyTo" BOOLEAN, | ||
"transformer" TEXT, | ||
"authorizationUserId" UUID NOT NULL, | ||
"envelopeId" UUID NOT NULL, | ||
"parentId" UUID, | ||
"createdBy" UUID, | ||
"resourceId" UUID, | ||
"createdAt" TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" TIMESTAMP(3), | ||
|
||
CONSTRAINT "EmailTemplate_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "VariableDefinition" ( | ||
"id" UUID NOT NULL DEFAULT gen_random_uuid(), | ||
"name" TEXT NOT NULL, | ||
"description" TEXT, | ||
"defaultValue" TEXT NOT NULL, | ||
"isRequired" BOOLEAN, | ||
"isConstant" BOOLEAN, | ||
"emailTemplateId" UUID, | ||
|
||
CONSTRAINT "VariableDefinition_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "AuthorizationUser" ( | ||
"id" UUID NOT NULL DEFAULT gen_random_uuid(), | ||
"userId" UUID NOT NULL, | ||
"authorization" TEXT NOT NULL, | ||
|
||
CONSTRAINT "AuthorizationUser_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "EmailEnvelope" ( | ||
"id" UUID NOT NULL DEFAULT gen_random_uuid(), | ||
"subject" TEXT, | ||
"fromId" UUID NOT NULL, | ||
"replyToId" UUID NOT NULL, | ||
|
||
CONSTRAINT "EmailEnvelope_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "EmailAddress" ( | ||
"id" UUID NOT NULL DEFAULT gen_random_uuid(), | ||
"value" TEXT NOT NULL, | ||
"type" "EmailAddressType" NOT NULL, | ||
|
||
CONSTRAINT "EmailAddress_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "_EmailAddressToEmailEnvelope" ( | ||
"A" UUID NOT NULL, | ||
"B" UUID NOT NULL | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "_EmailAddressToEmailEnvelope_AB_unique" ON "_EmailAddressToEmailEnvelope"("A", "B"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "_EmailAddressToEmailEnvelope_B_index" ON "_EmailAddressToEmailEnvelope"("B"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "EmailTemplate" ADD CONSTRAINT "EmailTemplate_authorizationUserId_fkey" FOREIGN KEY ("authorizationUserId") REFERENCES "AuthorizationUser"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "EmailTemplate" ADD CONSTRAINT "EmailTemplate_envelopeId_fkey" FOREIGN KEY ("envelopeId") REFERENCES "EmailEnvelope"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "EmailTemplate" ADD CONSTRAINT "EmailTemplate_parentId_fkey" FOREIGN KEY ("parentId") REFERENCES "EmailTemplate"("id") ON DELETE SET NULL ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "VariableDefinition" ADD CONSTRAINT "VariableDefinition_emailTemplateId_fkey" FOREIGN KEY ("emailTemplateId") REFERENCES "EmailTemplate"("id") ON DELETE SET NULL ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "EmailEnvelope" ADD CONSTRAINT "EmailEnvelope_fromId_fkey" FOREIGN KEY ("fromId") REFERENCES "EmailAddress"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "EmailEnvelope" ADD CONSTRAINT "EmailEnvelope_replyToId_fkey" FOREIGN KEY ("replyToId") REFERENCES "EmailAddress"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "_EmailAddressToEmailEnvelope" ADD CONSTRAINT "_EmailAddressToEmailEnvelope_A_fkey" FOREIGN KEY ("A") REFERENCES "EmailAddress"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "_EmailAddressToEmailEnvelope" ADD CONSTRAINT "_EmailAddressToEmailEnvelope_B_fkey" FOREIGN KEY ("B") REFERENCES "EmailEnvelope"("id") ON DELETE CASCADE ON UPDATE CASCADE; |
40 changes: 40 additions & 0 deletions
40
prisma/migrations/20231106181918_make_fields_optional/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
Warnings: | ||
- Made the column `createdAt` on table `EmailTemplate` required. This step will fail if there are existing NULL values in that column. | ||
- Made the column `updatedAt` on table `EmailTemplate` required. This step will fail if there are existing NULL values in that column. | ||
*/ | ||
-- DropForeignKey | ||
ALTER TABLE "EmailEnvelope" DROP CONSTRAINT "EmailEnvelope_fromId_fkey"; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE "EmailEnvelope" DROP CONSTRAINT "EmailEnvelope_replyToId_fkey"; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE "EmailTemplate" DROP CONSTRAINT "EmailTemplate_authorizationUserId_fkey"; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE "EmailTemplate" DROP CONSTRAINT "EmailTemplate_envelopeId_fkey"; | ||
|
||
-- AlterTable | ||
ALTER TABLE "EmailEnvelope" ALTER COLUMN "fromId" DROP NOT NULL, | ||
ALTER COLUMN "replyToId" DROP NOT NULL; | ||
|
||
-- AlterTable | ||
ALTER TABLE "EmailTemplate" ALTER COLUMN "authorizationUserId" DROP NOT NULL, | ||
ALTER COLUMN "envelopeId" DROP NOT NULL, | ||
ALTER COLUMN "createdAt" SET NOT NULL, | ||
ALTER COLUMN "updatedAt" SET NOT NULL; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "EmailTemplate" ADD CONSTRAINT "EmailTemplate_authorizationUserId_fkey" FOREIGN KEY ("authorizationUserId") REFERENCES "AuthorizationUser"("id") ON DELETE SET NULL ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "EmailTemplate" ADD CONSTRAINT "EmailTemplate_envelopeId_fkey" FOREIGN KEY ("envelopeId") REFERENCES "EmailEnvelope"("id") ON DELETE SET NULL ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "EmailEnvelope" ADD CONSTRAINT "EmailEnvelope_fromId_fkey" FOREIGN KEY ("fromId") REFERENCES "EmailAddress"("id") ON DELETE SET NULL ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "EmailEnvelope" ADD CONSTRAINT "EmailEnvelope_replyToId_fkey" FOREIGN KEY ("replyToId") REFERENCES "EmailAddress"("id") ON DELETE SET NULL ON UPDATE CASCADE; |
10 changes: 10 additions & 0 deletions
10
prisma/migrations/20231106191208_iam_required/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
Warnings: | ||
- Made the column `createdBy` on table `EmailTemplate` required. This step will fail if there are existing NULL values in that column. | ||
- Made the column `resourceId` on table `EmailTemplate` required. This step will fail if there are existing NULL values in that column. | ||
*/ | ||
-- AlterTable | ||
ALTER TABLE "EmailTemplate" ALTER COLUMN "createdBy" SET NOT NULL, | ||
ALTER COLUMN "resourceId" SET NOT NULL; |
2 changes: 2 additions & 0 deletions
2
prisma/migrations/20231107153805_variable_default_value_not_required/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- AlterTable | ||
ALTER TABLE "VariableDefinition" ALTER COLUMN "defaultValue" DROP NOT NULL; |
2 changes: 2 additions & 0 deletions
2
prisma/migrations/20231107231433_add_email_template_description/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- AlterTable | ||
ALTER TABLE "EmailTemplate" ADD COLUMN "description" TEXT NOT NULL DEFAULT ''; |
2 changes: 2 additions & 0 deletions
2
prisma/migrations/20231107231511_remove_email_template_description_default/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- AlterTable | ||
ALTER TABLE "EmailTemplate" ALTER COLUMN "description" DROP DEFAULT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Please do not edit this file manually | ||
# It should be added in your version-control system (i.e. Git) | ||
provider = "postgresql" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
datasource db { | ||
provider = "postgresql" | ||
url = env("DATABASE_URL") | ||
} | ||
|
||
generator client { | ||
provider = "prisma-client-js" | ||
} | ||
|
||
model EmailTemplate { | ||
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid | ||
description String | ||
content String | ||
verifyReplyTo Boolean? | ||
transformer String? | ||
authorizationUser AuthorizationUser? @relation(fields: [authorizationUserId], references: [id]) | ||
authorizationUserId String? @db.Uuid | ||
envelope EmailEnvelope? @relation(fields: [envelopeId], references: [id]) | ||
envelopeId String? @db.Uuid | ||
parent EmailTemplate? @relation("EmailTemplateParent", fields: [parentId], references: [id]) | ||
parentId String? @db.Uuid | ||
linked EmailTemplate[] @relation("EmailTemplateParent") | ||
variables VariableDefinition[] | ||
// IAM data | ||
createdBy String @db.Uuid | ||
resourceId String @db.Uuid | ||
// Timestamps | ||
createdAt DateTime @default(now()) | ||
updatedAt DateTime @updatedAt | ||
} | ||
|
||
model VariableDefinition { | ||
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid | ||
name String | ||
description String? | ||
defaultValue String? | ||
isRequired Boolean? | ||
isConstant Boolean? | ||
EmailTemplate EmailTemplate? @relation(fields: [emailTemplateId], references: [id]) | ||
emailTemplateId String? @db.Uuid | ||
} | ||
|
||
model AuthorizationUser { | ||
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid | ||
userId String @db.Uuid | ||
// @sf-hide | ||
authorization String | ||
EmailTemplate EmailTemplate[] | ||
} | ||
|
||
model EmailEnvelope { | ||
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid | ||
subject String? | ||
EmailTemplate EmailTemplate[] | ||
from EmailAddress? @relation("FromEnvelopes", fields: [fromId], references: [id]) | ||
fromId String? @db.Uuid | ||
replyTo EmailAddress? @relation("ReplyToEnvelopes", fields: [replyToId], references: [id]) | ||
replyToId String? @db.Uuid | ||
to EmailAddress[] | ||
} | ||
|
||
model EmailAddress { | ||
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid | ||
value String | ||
type EmailAddressType | ||
ToEnvelopes EmailEnvelope[] | ||
FromEnvelopes EmailEnvelope[] @relation("FromEnvelopes") | ||
ReplyToEnvelopes EmailEnvelope[] @relation("ReplyToEnvelopes") | ||
} | ||
|
||
enum EmailAddressType { | ||
EMAIL_ADDRESS | ||
EMAIL_ID | ||
USER_ID | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.