Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

feat: add VisitorGroup and LinkVisitorGroup models to Prisma schema

Cursor Agent9bbfab5f11e6
diff --git a/prisma/migrations/20260212000000_add_visitor_groups/migration.sql b/prisma/migrations/20260212000000_add_visitor_groups/migration.sql
new file mode 100644
index 00000000..62f46304
--- /dev/null
+++ b/prisma/migrations/20260212000000_add_visitor_groups/migration.sql
@@ -0,0 +1,42 @@
+-- CreateTable
+CREATE TABLE "VisitorGroup" (
+ "id" TEXT NOT NULL,
+ "name" TEXT NOT NULL,
+ "emails" TEXT[],
+ "teamId" TEXT NOT NULL,
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ "updatedAt" TIMESTAMP(3) NOT NULL,
+
+ CONSTRAINT "VisitorGroup_pkey" PRIMARY KEY ("id")
+);
+
+-- CreateTable
+CREATE TABLE "LinkVisitorGroup" (
+ "id" TEXT NOT NULL,
+ "linkId" TEXT NOT NULL,
+ "visitorGroupId" TEXT NOT NULL,
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
+
+ CONSTRAINT "LinkVisitorGroup_pkey" PRIMARY KEY ("id")
+);
+
+-- CreateIndex
+CREATE INDEX "VisitorGroup_teamId_idx" ON "VisitorGroup"("teamId");
+
+-- CreateIndex
+CREATE INDEX "LinkVisitorGroup_linkId_idx" ON "LinkVisitorGroup"("linkId");
+
+-- CreateIndex
+CREATE INDEX "LinkVisitorGroup_visitorGroupId_idx" ON "LinkVisitorGroup"("visitorGroupId");
+
+-- CreateIndex
+CREATE UNIQUE INDEX "LinkVisitorGroup_linkId_visitorGroupId_key" ON "LinkVisitorGroup"("linkId", "visitorGroupId");
+
+-- AddForeignKey
+ALTER TABLE "VisitorGroup" ADD CONSTRAINT "VisitorGroup_teamId_fkey" FOREIGN KEY ("teamId") REFERENCES "Team"("id") ON DELETE CASCADE ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE "LinkVisitorGroup" ADD CONSTRAINT "LinkVisitorGroup_linkId_fkey" FOREIGN KEY ("linkId") REFERENCES "Link"("id") ON DELETE CASCADE ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE "LinkVisitorGroup" ADD CONSTRAINT "LinkVisitorGroup_visitorGroupId_fkey" FOREIGN KEY ("visitorGroupId") REFERENCES "VisitorGroup"("id") ON DELETE CASCADE ON UPDATE CASCADE;
diff --git a/prisma/schema/link.prisma b/prisma/schema/link.prisma
index cb956330..29b7aa6f 100644
--- a/prisma/schema/link.prisma
+++ b/prisma/schema/link.prisma
@@ -93,6 +93,9 @@ model Link {
tags TagItem[]
viewerInvitations ViewerInvitation[]
+ // visitor groups for allow-list
+ visitorGroups LinkVisitorGroup[]
+
// workflow entry link
workflow Workflow?
@@ -162,6 +165,36 @@ enum CustomFieldType {
MULTI_SELECT
}
+model VisitorGroup {
+ id String @id @default(cuid())
+ name String
+ emails String[] // List of emails and domains (e.g., "[email protected]", "@example.org")
+
+ teamId String
+ team Team @relation(fields: [teamId], references: [id], onDelete: Cascade)
+
+ links LinkVisitorGroup[]
+
+ createdAt DateTime @default(now())
+ updatedAt DateTime @updatedAt
+
+ @@index([teamId])
+}
+
+model LinkVisitorGroup {
+ id String @id @default(cuid())
+ linkId String
+ link Link @relation(fields: [linkId], references: [id], onDelete: Cascade)
+ visitorGroupId String
+ visitorGroup VisitorGroup @relation(fields: [visitorGroupId], references: [id], onDelete: Cascade)
+
+ createdAt DateTime @default(now())
+
+ @@unique([linkId, visitorGroupId])
+ @@index([linkId])
+ @@index([visitorGroupId])
+}
+
model CustomField {
id String @id @default(cuid())
createdAt DateTime @default(now())
diff --git a/prisma/schema/team.prisma b/prisma/schema/team.prisma
index 94b5a9dd..6a505546 100644
--- a/prisma/schema/team.prisma
+++ b/prisma/schema/team.prisma
@@ -11,8 +11,9 @@ model Team {
brand Brand?
datarooms Dataroom[]
agreements Agreement[]
- viewerGroups ViewerGroup[]
- viewers Viewer[]
+ viewerGroups ViewerGroup[]
+ visitorGroups VisitorGroup[]
+ viewers Viewer[]
permissionGroups PermissionGroup[]
linkPresets LinkPreset[] // Link presets for the team