Add CRUD for galleries
This commit is contained in:
14
prisma/migrations/20250624201728_init_gallery/migration.sql
Normal file
14
prisma/migrations/20250624201728_init_gallery/migration.sql
Normal 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");
|
15
prisma/migrations/20250624212636_add_albums/migration.sql
Normal file
15
prisma/migrations/20250624212636_add_albums/migration.sql
Normal 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;
|
3
prisma/migrations/migration_lock.toml
Normal file
3
prisma/migrations/migration_lock.toml
Normal 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"
|
@ -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[]
|
||||
}
|
||||
|
Reference in New Issue
Block a user