Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions prisma/migrations/20260405073828_add_folder_model/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
-- AlterTable
ALTER TABLE "Document" ADD COLUMN "folderId" INTEGER;

-- AlterTable
ALTER TABLE "Media" ADD COLUMN "folderId" INTEGER;

-- CreateTable
CREATE TABLE "Folder" (
"id" SERIAL NOT NULL,
"name" TEXT NOT NULL,
"parentId" INTEGER,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,

CONSTRAINT "Folder_pkey" PRIMARY KEY ("id")
);

-- AddForeignKey
ALTER TABLE "Document" ADD CONSTRAINT "Document_folderId_fkey" FOREIGN KEY ("folderId") REFERENCES "Folder"("id") ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Media" ADD CONSTRAINT "Media_folderId_fkey" FOREIGN KEY ("folderId") REFERENCES "Folder"("id") ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Folder" ADD CONSTRAINT "Folder_parentId_fkey" FOREIGN KEY ("parentId") REFERENCES "Folder"("id") ON DELETE SET NULL ON UPDATE CASCADE;
16 changes: 16 additions & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ model Document {
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
archivedAt DateTime?
folderId Int?
folder Folder? @relation("FolderDocuments", fields: [folderId], references: [id])
}

model Version {
Expand All @@ -35,6 +37,8 @@ model Media {
size Int
contentType String?
createdAt DateTime @default(now())
folderId Int?
folder Folder? @relation("FolderMedia", fields: [folderId], references: [id])
}

model Route {
Expand All @@ -44,4 +48,16 @@ model Route {
document Document @relation(fields: [documentId], references: [id], onDelete: Cascade)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}

model Folder {
id Int @id @default(autoincrement())
name String
parentId Int?
parent Folder? @relation("FolderNesting", fields: [parentId], references: [id])
children Folder[] @relation("FolderNesting")
documents Document[] @relation("FolderDocuments")
media Media[] @relation("FolderMedia")
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
Loading
Loading