Skip to content

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

feat: add db index for foreign keys

Marc Seitza0f83772c1cc
diff --git a/prisma/migrations/20231128064540_add_indices/migration.sql b/prisma/migrations/20231128064540_add_indices/migration.sql
new file mode 100644
index 00000000..9f49322e
--- /dev/null
+++ b/prisma/migrations/20231128064540_add_indices/migration.sql
@@ -0,0 +1,26 @@
+-- CreateIndex
+CREATE INDEX "Document_ownerId_idx" ON "Document"("ownerId");
+
+-- CreateIndex
+CREATE INDEX "Document_teamId_idx" ON "Document"("teamId");
+
+-- CreateIndex
+CREATE INDEX "DocumentPage_versionId_idx" ON "DocumentPage"("versionId");
+
+-- CreateIndex
+CREATE INDEX "DocumentVersion_documentId_idx" ON "DocumentVersion"("documentId");
+
+-- CreateIndex
+CREATE INDEX "Domain_userId_idx" ON "Domain"("userId");
+
+-- CreateIndex
+CREATE INDEX "Domain_teamId_idx" ON "Domain"("teamId");
+
+-- CreateIndex
+CREATE INDEX "Link_documentId_idx" ON "Link"("documentId");
+
+-- CreateIndex
+CREATE INDEX "View_linkId_idx" ON "View"("linkId");
+
+-- CreateIndex
+CREATE INDEX "View_documentId_idx" ON "View"("documentId");
diff --git a/prisma/schema.prisma b/prisma/schema.prisma
index 67159498..063698eb 100644
--- a/prisma/schema.prisma
+++ b/prisma/schema.prisma
@@ -113,6 +113,9 @@ model Document {
links Link[]
views View[]
versions DocumentVersion[]
+
+ @@index([ownerId])
+ @@index([teamId])
}
model DocumentVersion {
@@ -130,6 +133,7 @@ model DocumentVersion {
updatedAt DateTime @updatedAt
@@unique([versionNumber, documentId])
+ @@index([documentId])
}
model DocumentPage {
@@ -142,6 +146,7 @@ model DocumentPage {
updatedAt DateTime @updatedAt
@@unique([pageNumber, versionId])
+ @@index([versionId])
}
model Link {
@@ -166,6 +171,7 @@ model Link {
enableNotification Boolean? @default(true) // Optional give user a option to pause/resume the notifications
@@unique([domainSlug, slug])
+ @@index([documentId])
}
model Domain {
@@ -180,6 +186,9 @@ model Domain {
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
links Link[] // links associated with this domain
+
+ @@index([userId])
+ @@index([teamId])
}
model View {
@@ -190,6 +199,9 @@ model View {
documentId String
viewerEmail String? // Email of the viewer if known
viewedAt DateTime @default(now())
+
+ @@index([linkId])
+ @@index([documentId])
}
model Invitation {
@@ -200,7 +212,7 @@ model Invitation {
createdAt DateTime @default(now())
token String @unique
- @@unique([email,teamId])
+ @@unique([email, teamId])
}
enum EmailType {
@@ -210,15 +222,16 @@ enum EmailType {
FIRST_TRIAL_END_REMINDER_EMAIL
FINAL_TRIAL_END_REMINDER_EMAIL
}
+
model SentEmail {
- id String @id @default(cuid())
- type EmailType
- recipient String // Email address of the recipient
- marketing Boolean @default(false)
- createdAt DateTime @default(now())
- team Team @relation(fields: [teamId], references: [id], onDelete: Cascade)
- teamId String
- domainSlug String? // Domain that triggered the email. This can be nullable, representing emails not triggered by domains
+ id String @id @default(cuid())
+ type EmailType
+ recipient String // Email address of the recipient
+ marketing Boolean @default(false)
+ createdAt DateTime @default(now())
+ team Team @relation(fields: [teamId], references: [id], onDelete: Cascade)
+ teamId String
+ domainSlug String? // Domain that triggered the email. This can be nullable, representing emails not triggered by domains
@@index([teamId])
-}
\ No newline at end of file
+}