Open-Generative-AI/prisma/schema.prisma
Anuragp22 47dd61f33a feat(batch): add Prisma schema and Postgres wiring for batch feature
First slice of the CSV-driven batch video-generation feature. Introduces
the four-table schema (trainers, studios, batches, jobs) that the worker
and new /batch UI will operate on, plus the infrastructure glue so the
schema can be applied locally and in the docker-compose stack.

- prisma/schema.prisma: Trainer, Studio, Batch, Job models with the
  indexes the worker's claim query will need
  ([batchId, status] and [status, nextAttemptAt]).
- prisma/migrations/20260423011041_init_batch_schema: initial migration
  generated and applied against the compose Postgres.
- lib/prisma.js: standard Next.js PrismaClient singleton, reused across
  the web API routes and the worker process.
- docker-compose.yml: map Postgres to host port 5433 to avoid colliding
  with a pre-existing local Postgres on 5432; wire MUAPI_API_KEY env
  through web and worker; add uploads_data volume mounted at
  /data/uploads for slice-2 trainer/studio image backups.
- .env.example: documented DATABASE_URL (5433 for host, 5432 for
  in-compose) and MUAPI_API_KEY placeholders.
- .gitignore: ignore /data/uploads/ now so future runtime uploads
  don't end up tracked.

Also downgraded prisma from 7.x to ^6 since 7 moved datasource config
out of schema.prisma into a separate prisma.config.ts (breaking change
we don't need to absorb yet).

No API routes, worker, or UI in this slice — those land in the next
branches (feat/trainers-studios-crud, feat/batch-create-csv, etc).
2026-04-23 06:41:31 +05:30

83 lines
2.6 KiB
Text

generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model Trainer {
id String @id @default(cuid())
name String
csvLabel String? @unique @map("csv_label")
imageUrl String @map("image_url")
localPath String? @map("local_path")
createdAt DateTime @default(now()) @map("created_at")
jobs Job[]
@@map("trainers")
}
model Studio {
id String @id @default(cuid())
name String
csvLabel String? @unique @map("csv_label")
imageUrl String @map("image_url")
localPath String? @map("local_path")
createdAt DateTime @default(now()) @map("created_at")
jobs Job[]
@@map("studios")
}
model Batch {
id String @id @default(cuid())
name String
model String @default("seedance-v2.0-i2v")
duration Int @default(15)
quality String @default("basic")
aspectRatio String @default("16:9") @map("aspect_ratio")
concurrency Int @default(5)
status String @default("draft")
total Int @default(0)
done Int @default(0)
failed Int @default(0)
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
jobs Job[]
@@map("batches")
}
model Job {
id String @id @default(cuid())
batchId String @map("batch_id")
rowIndex Int @map("row_index")
practiceName String @map("practice_name")
trainerId String? @map("trainer_id")
studioId String? @map("studio_id")
prompt String
startPosition String? @map("start_position")
cameraAngle String? @map("camera_angle")
aspectRatio String @default("16:9") @map("aspect_ratio")
duration Int @default(15)
quality String @default("basic")
status String @default("queued")
retries Int @default(0)
muapiRequestId String? @map("muapi_request_id")
videoUrl String? @map("video_url")
error String?
nextAttemptAt DateTime? @map("next_attempt_at")
startedAt DateTime? @map("started_at")
completedAt DateTime? @map("completed_at")
createdAt DateTime @default(now()) @map("created_at")
batch Batch @relation(fields: [batchId], references: [id], onDelete: Cascade)
trainer Trainer? @relation(fields: [trainerId], references: [id])
studio Studio? @relation(fields: [studioId], references: [id])
@@index([batchId, status])
@@index([status, nextAttemptAt])
@@map("jobs")
}