feat: add document folders

This commit is contained in:
Catalin Pit
2025-03-17 16:31:36 +02:00
parent 55b7697316
commit 4156f2afce

View File

@@ -56,6 +56,7 @@ model User {
accounts Account[] accounts Account[]
sessions Session[] sessions Session[]
documents Document[] documents Document[]
folders Folder[]
subscriptions Subscription[] subscriptions Subscription[]
passwordResetTokens PasswordResetToken[] passwordResetTokens PasswordResetToken[]
ownedTeams Team[] ownedTeams Team[]
@@ -312,6 +313,25 @@ enum DocumentVisibility {
ADMIN ADMIN
} }
model Folder {
id Int @id @default(autoincrement())
name String
userId Int
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
teamId Int?
team Team? @relation(fields: [teamId], references: [id], onDelete: Cascade)
parentId Int?
parent Folder? @relation("FolderToFolder", fields: [parentId], references: [id], onDelete: Cascade)
subfolders Folder[] @relation("FolderToFolder")
documents Document[]
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
@@index([userId])
@@index([teamId])
@@index([parentId])
}
/// @zod.import(["import { ZDocumentAuthOptionsSchema } from '@documenso/lib/types/document-auth';", "import { ZDocumentFormValuesSchema } from '@documenso/lib/types/document-form-values';"]) /// @zod.import(["import { ZDocumentAuthOptionsSchema } from '@documenso/lib/types/document-auth';", "import { ZDocumentFormValuesSchema } from '@documenso/lib/types/document-form-values';"])
model Document { model Document {
id Int @id @default(autoincrement()) id Int @id @default(autoincrement())
@@ -340,10 +360,13 @@ model Document {
source DocumentSource source DocumentSource
auditLogs DocumentAuditLog[] auditLogs DocumentAuditLog[]
Folder Folder? @relation(fields: [folderId], references: [id])
folderId Int?
@@unique([documentDataId]) @@unique([documentDataId])
@@index([userId]) @@index([userId])
@@index([status]) @@index([status])
@@index([folderId])
} }
model DocumentAuditLog { model DocumentAuditLog {
@@ -579,6 +602,7 @@ model Team {
documents Document[] documents Document[]
templates Template[] templates Template[]
folders Folder[]
apiTokens ApiToken[] apiTokens ApiToken[]
webhooks Webhook[] webhooks Webhook[]
} }