first commit
This commit is contained in:
103
prisma/schema.prisma
Normal file
103
prisma/schema.prisma
Normal file
@@ -0,0 +1,103 @@
|
||||
// Prisma Schema for Netflix Scraper API
|
||||
// Database: PostgreSQL
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// Content Tables
|
||||
// ============================================
|
||||
|
||||
/// Main content table for scraped Netflix data
|
||||
model Content {
|
||||
id String @id @default(uuid())
|
||||
url String @unique @db.VarChar(500)
|
||||
title String @db.VarChar(255)
|
||||
year Int?
|
||||
plot String? @db.Text
|
||||
backdropUrl String? @db.Text
|
||||
ageRating String? @db.VarChar(10)
|
||||
type String @default("movie") @db.VarChar(10) // movie or tvshow
|
||||
currentSeason Int? // Current season number for TV shows
|
||||
|
||||
// Relations
|
||||
genres ContentGenre[]
|
||||
castMembers CastMember[]
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@index([url])
|
||||
@@index([title])
|
||||
@@index([year])
|
||||
@@index([type])
|
||||
@@index([currentSeason])
|
||||
@@map("content")
|
||||
}
|
||||
|
||||
/// Genres lookup table
|
||||
model Genre {
|
||||
id String @id @default(uuid())
|
||||
name String @unique @db.VarChar(100)
|
||||
|
||||
// Relations
|
||||
contents ContentGenre[]
|
||||
|
||||
@@index([name])
|
||||
@@map("genres")
|
||||
}
|
||||
|
||||
/// Content-Genre many-to-many relationship
|
||||
model ContentGenre {
|
||||
contentId String
|
||||
genreId String
|
||||
|
||||
content Content @relation(fields: [contentId], references: [id], onDelete: Cascade)
|
||||
genre Genre @relation(fields: [genreId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@id([contentId, genreId])
|
||||
@@map("content_genres")
|
||||
}
|
||||
|
||||
/// Cast members for content
|
||||
model CastMember {
|
||||
id String @id @default(uuid())
|
||||
contentId String
|
||||
name String @db.VarChar(255)
|
||||
|
||||
content Content @relation(fields: [contentId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@index([contentId])
|
||||
@@index([name])
|
||||
@@map("cast_members")
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// Job Queue Table (for async processing)
|
||||
// ============================================
|
||||
|
||||
/// Scrape job queue
|
||||
model ScrapeJob {
|
||||
id String @id @default(uuid())
|
||||
url String @db.VarChar(500)
|
||||
status String @default("pending") @db.VarChar(20) // pending, processing, completed, failed
|
||||
progress Int @default(0)
|
||||
step String? @db.VarChar(100)
|
||||
error String? @db.Text
|
||||
|
||||
// Result stored as JSON when completed
|
||||
result Json?
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@index([url])
|
||||
@@index([status])
|
||||
@@map("scrape_jobs")
|
||||
}
|
||||
Reference in New Issue
Block a user