datasource db { provider = "sqlite" url = env("DATABASE_URL") } generator client { provider = "prisma-client-js" } model Game { id String @id @default(cuid()) title String slug String @unique description String? releaseDate DateTime? igdbId Int? @unique rawgId Int? @unique thegamesdbId Int? @unique extra String? // JSON serialized (usar parse/stringify al guardar/leer) para compatibilidad con SQLite createdAt DateTime @default(now()) updatedAt DateTime @updatedAt romFiles RomFile[] artworks Artwork[] purchases Purchase[] gamePlatforms GamePlatform[] priceHistories PriceHistory[] tags Tag[] @@index([title]) } model Platform { id String @id @default(cuid()) name String slug String @unique generation Int? gamePlatforms GamePlatform[] } model GamePlatform { id String @id @default(cuid()) game Game @relation(fields: [gameId], references: [id]) gameId String platform Platform @relation(fields: [platformId], references: [id]) platformId String @@unique([gameId, platformId]) } model RomFile { id String @id @default(cuid()) path String filename String checksum String @unique size Int format String hashes String? // JSON serialized (ej.: {"crc32": "...", "md5": "..."}) game Game? @relation(fields: [gameId], references: [id]) gameId String? addedAt DateTime @default(now()) lastSeenAt DateTime? status String @default("active") @@index([checksum]) } model Artwork { id String @id @default(cuid()) game Game @relation(fields: [gameId], references: [id]) gameId String type String sourceUrl String localPath String? width Int? height Int? fetchedAt DateTime @default(now()) } model Purchase { id String @id @default(cuid()) game Game @relation(fields: [gameId], references: [id]) gameId String priceCents Int currency String store String? date DateTime receiptPath String? } model Tag { id String @id @default(cuid()) name String @unique games Game[] } model PriceHistory { id String @id @default(cuid()) game Game @relation(fields: [gameId], references: [id]) gameId String priceCents Int currency String recordedAt DateTime @default(now()) source String? } // Metadatos: // Autor: GitHub Copilot // Última actualización: 2026-02-07