diff --git a/prisma/migrations/20240912193038_create_invitations_table/migration.sql b/prisma/migrations/20240912193038_create_invitations_table/migration.sql new file mode 100644 index 0000000000..6d86972c4c --- /dev/null +++ b/prisma/migrations/20240912193038_create_invitations_table/migration.sql @@ -0,0 +1,12 @@ +-- CreateTable +CREATE TABLE "Invitation" ( + "id" TEXT NOT NULL, + "email" TEXT NOT NULL, + "expires" TIMESTAMP(3) NOT NULL, + "templateId" TEXT NOT NULL, + + CONSTRAINT "Invitation_pkey" PRIMARY KEY ("id") +); + +-- AddForeignKey +ALTER TABLE "Invitation" ADD CONSTRAINT "Invitation_templateId_fkey" FOREIGN KEY ("templateId") REFERENCES "Template"("id") ON DELETE CASCADE ON UPDATE NO ACTION; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 33510669ad..a1b08f7507 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -59,7 +59,8 @@ model Template { bearerToken String? ttl DateTime? users User[] - closingDate DateTime? @db.Timestamptz(6) + closingDate DateTime? @db.Timestamptz(6) + invitations Invitation[] } model DeliveryOption { @@ -145,3 +146,11 @@ model MagicLink { token String @unique expires DateTime } + +model Invitation { + id String @id @default(cuid()) + email String + expires DateTime + templateId String + template Template @relation(fields: [templateId], references: [id], onDelete: Cascade, onUpdate: NoAction) +} \ No newline at end of file