- Add PlayerState model to database schema for storing game states - Create player identifier system (UUID-based) for cross-domain sync - Implement API endpoints for loading/saving player states - Refactor gameState hook to use backend storage with localStorage fallback - Support synchronization between hoerdle.de and hördle.de - Migration automatically runs on Docker container start
104 lines
3.2 KiB
Plaintext
104 lines
3.2 KiB
Plaintext
// This is your Prisma schema file,
|
|
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
|
|
|
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "sqlite"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
model Song {
|
|
id Int @id @default(autoincrement())
|
|
title String
|
|
artist String
|
|
filename String // Filename in public/uploads
|
|
coverImage String? // Filename in public/uploads/covers
|
|
releaseYear Int? // Release year from iTunes
|
|
createdAt DateTime @default(now())
|
|
puzzles DailyPuzzle[]
|
|
genres Genre[]
|
|
specials SpecialSong[]
|
|
averageRating Float @default(0)
|
|
ratingCount Int @default(0)
|
|
excludeFromGlobal Boolean @default(false)
|
|
}
|
|
|
|
model Genre {
|
|
id Int @id @default(autoincrement())
|
|
name Json // Multilingual: { "de": "Rock", "en": "Rock" }
|
|
subtitle Json? // Multilingual
|
|
active Boolean @default(true)
|
|
songs Song[]
|
|
dailyPuzzles DailyPuzzle[]
|
|
}
|
|
|
|
model Special {
|
|
id Int @id @default(autoincrement())
|
|
name Json // Multilingual
|
|
subtitle Json? // Multilingual
|
|
maxAttempts Int @default(7)
|
|
unlockSteps String // JSON string: e.g. "[2, 4, 7, 11, 16, 30]"
|
|
createdAt DateTime @default(now())
|
|
launchDate DateTime?
|
|
endDate DateTime?
|
|
curator String?
|
|
songs SpecialSong[]
|
|
puzzles DailyPuzzle[]
|
|
news News[]
|
|
}
|
|
|
|
model SpecialSong {
|
|
id Int @id @default(autoincrement())
|
|
specialId Int
|
|
special Special @relation(fields: [specialId], references: [id], onDelete: Cascade)
|
|
songId Int
|
|
song Song @relation(fields: [songId], references: [id], onDelete: Cascade)
|
|
startTime Int @default(0) // Start time in seconds
|
|
order Int? // For manual ordering
|
|
|
|
@@unique([specialId, songId])
|
|
}
|
|
|
|
model DailyPuzzle {
|
|
id Int @id @default(autoincrement())
|
|
date String // Format: YYYY-MM-DD
|
|
songId Int
|
|
song Song @relation(fields: [songId], references: [id], onDelete: Cascade)
|
|
genreId Int?
|
|
genre Genre? @relation(fields: [genreId], references: [id])
|
|
specialId Int?
|
|
special Special? @relation(fields: [specialId], references: [id])
|
|
|
|
@@unique([date, genreId, specialId])
|
|
}
|
|
|
|
model News {
|
|
id Int @id @default(autoincrement())
|
|
title Json // Multilingual
|
|
content Json // Multilingual
|
|
author String? // Optional: curator/admin name
|
|
publishedAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
featured Boolean @default(false) // Highlight important news
|
|
specialId Int? // Optional: link to a special
|
|
special Special? @relation(fields: [specialId], references: [id], onDelete: SetNull)
|
|
|
|
@@index([publishedAt])
|
|
}
|
|
|
|
model PlayerState {
|
|
id Int @id @default(autoincrement())
|
|
identifier String // UUID des Spielers (für Cross-Domain-Sync)
|
|
genreKey String // Genre-Name oder "global" oder "special:<name>"
|
|
gameState String // JSON-String des GameState
|
|
statistics String // JSON-String der Statistics
|
|
lastPlayed DateTime @updatedAt
|
|
createdAt DateTime @default(now())
|
|
|
|
@@unique([identifier, genreKey])
|
|
@@index([identifier])
|
|
}
|