jedmund-svelte/prisma/schema.prisma
Justin Edmund 38b62168e9 feat(database): redesign album system with content support and geolocation
- Add album content field for rich text/structured content
- Add geolocation support for albums with position and zoom level
- Remove direct photo-album relationship in favor of MediaAlbum join table
- Support many-to-many relationships between media and albums
- Add Album relation to Universe model for better organization

This enables albums to have rich content beyond just photos and supports
geographic data for location-based albums.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-24 01:10:54 +01:00

178 lines
5.4 KiB
Text

generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model Project {
id Int @id @default(autoincrement())
slug String @unique @db.VarChar(255)
title String @db.VarChar(255)
subtitle String? @db.VarChar(255)
description String?
year Int
client String? @db.VarChar(255)
role String? @db.VarChar(255)
featuredImage String? @db.VarChar(500)
gallery Json?
externalUrl String? @db.VarChar(500)
caseStudyContent Json?
displayOrder Int @default(0)
status String @default("draft") @db.VarChar(50)
publishedAt DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
backgroundColor String? @db.VarChar(50)
highlightColor String? @db.VarChar(50)
logoUrl String? @db.VarChar(500)
password String? @db.VarChar(255)
projectType String @default("work") @db.VarChar(50)
@@index([slug])
@@index([status])
}
model Post {
id Int @id @default(autoincrement())
slug String @unique @db.VarChar(255)
postType String @db.VarChar(50)
title String? @db.VarChar(255)
content Json?
featuredImage String? @db.VarChar(500)
tags Json?
status String @default("draft") @db.VarChar(50)
publishedAt DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
attachments Json?
@@index([slug])
@@index([status])
@@index([postType])
}
model Album {
id Int @id @default(autoincrement())
slug String @unique @db.VarChar(255)
title String @db.VarChar(255)
description String?
date DateTime?
location String? @db.VarChar(255)
coverPhotoId Int?
status String @default("draft") @db.VarChar(50)
showInUniverse Boolean @default(false)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
content Json?
publishedAt DateTime?
media AlbumMedia[]
geoLocations GeoLocation[]
@@index([slug])
@@index([status])
}
model Photo {
id Int @id @default(autoincrement())
filename String @db.VarChar(255)
url String @db.VarChar(500)
thumbnailUrl String? @db.VarChar(500)
width Int?
height Int?
exifData Json?
caption String?
displayOrder Int @default(0)
slug String? @unique @db.VarChar(255)
title String? @db.VarChar(255)
description String?
status String @default("draft") @db.VarChar(50)
publishedAt DateTime?
showInPhotos Boolean @default(true)
createdAt DateTime @default(now())
mediaId Int?
dominantColor String? @db.VarChar(7)
colors Json?
aspectRatio Float?
media Media? @relation(fields: [mediaId], references: [id])
@@index([slug])
@@index([status])
@@index([mediaId])
}
model Media {
id Int @id @default(autoincrement())
filename String @db.VarChar(255)
mimeType String @db.VarChar(100)
size Int
url String
thumbnailUrl String?
width Int?
height Int?
usedIn Json @default("[]")
createdAt DateTime @default(now())
description String?
originalName String? @db.VarChar(255)
updatedAt DateTime @updatedAt
isPhotography Boolean @default(false)
exifData Json?
photoCaption String?
photoTitle String? @db.VarChar(255)
photoDescription String?
photoSlug String? @unique @db.VarChar(255)
photoPublishedAt DateTime?
dominantColor String? @db.VarChar(7)
colors Json?
aspectRatio Float?
albums AlbumMedia[]
usage MediaUsage[]
photos Photo[]
}
model MediaUsage {
id Int @id @default(autoincrement())
mediaId Int
contentType String @db.VarChar(50)
contentId Int
fieldName String @db.VarChar(100)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
media Media @relation(fields: [mediaId], references: [id], onDelete: Cascade)
@@unique([mediaId, contentType, contentId, fieldName])
@@index([mediaId])
@@index([contentType, contentId])
}
model AlbumMedia {
id Int @id @default(autoincrement())
albumId Int
mediaId Int
displayOrder Int @default(0)
createdAt DateTime @default(now())
album Album @relation(fields: [albumId], references: [id], onDelete: Cascade)
media Media @relation(fields: [mediaId], references: [id], onDelete: Cascade)
@@unique([albumId, mediaId])
@@index([albumId])
@@index([mediaId])
}
model GeoLocation {
id Int @id @default(autoincrement())
albumId Int
latitude Float
longitude Float
title String @db.VarChar(255)
description String?
markerColor String? @db.VarChar(7)
order Int @default(0)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
album Album @relation(fields: [albumId], references: [id], onDelete: Cascade)
@@index([albumId])
}