Add CRUD for galleries

This commit is contained in:
2025-06-24 23:44:25 +02:00
parent edce8012eb
commit 0700592ebe
23 changed files with 1096 additions and 12 deletions

View File

@ -0,0 +1,14 @@
-- CreateTable
CREATE TABLE "Gallery" (
"id" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"name" TEXT NOT NULL,
"slug" TEXT NOT NULL,
"description" TEXT,
CONSTRAINT "Gallery_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "Gallery_slug_key" ON "Gallery"("slug");

View File

@ -0,0 +1,15 @@
-- CreateTable
CREATE TABLE "Album" (
"id" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"name" TEXT NOT NULL,
"slug" TEXT NOT NULL,
"description" TEXT,
"galleryId" TEXT,
CONSTRAINT "Album_pkey" PRIMARY KEY ("id")
);
-- AddForeignKey
ALTER TABLE "Album" ADD CONSTRAINT "Album_galleryId_fkey" FOREIGN KEY ("galleryId") REFERENCES "Gallery"("id") ON DELETE SET NULL ON UPDATE CASCADE;

View File

@ -0,0 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (e.g., Git)
provider = "postgresql"

View File

@ -13,3 +13,37 @@ datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model Gallery {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
name String
slug String @unique
description String?
// coverImageId String?
// coverImage Image? @relation("GalleryCoverImage", fields: [coverImageId], references: [id])
albums Album[]
}
model Album {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
name String
slug String
description String?
// coverImageId String?
galleryId String?
// coverImage Image? @relation("AlbumCoverImage", fields: [coverImageId], references: [id])
gallery Gallery? @relation(fields: [galleryId], references: [id])
// images Image[]
}