- 12 models: Organization, User, Account, Session, Project, Deliverable, DeliverableStage, StageAssignment, Revision, Comment, Notification, plus pipeline templates/dependencies - Prisma 7 adapter pattern with @prisma/adapter-pg - Seed script with 10 pipeline stages and dependency rules - Environment config (.env.example) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
342 lines
8.5 KiB
Text
342 lines
8.5 KiB
Text
generator client {
|
|
provider = "prisma-client"
|
|
output = "../src/generated/prisma"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
}
|
|
|
|
// ─── Enums ──────────────────────────────────────────────
|
|
|
|
enum Role {
|
|
ADMIN
|
|
PRODUCER
|
|
ARTIST
|
|
}
|
|
|
|
enum ProjectStatus {
|
|
ACTIVE
|
|
ON_HOLD
|
|
COMPLETED
|
|
ARCHIVED
|
|
}
|
|
|
|
enum Priority {
|
|
LOW
|
|
MEDIUM
|
|
HIGH
|
|
URGENT
|
|
}
|
|
|
|
enum DeliverableStatus {
|
|
NOT_STARTED
|
|
IN_PROGRESS
|
|
IN_REVIEW
|
|
APPROVED
|
|
ON_HOLD
|
|
}
|
|
|
|
enum StageStatus {
|
|
BLOCKED
|
|
NOT_STARTED
|
|
IN_PROGRESS
|
|
IN_REVIEW
|
|
CHANGES_REQUESTED
|
|
APPROVED
|
|
SKIPPED
|
|
}
|
|
|
|
enum RevisionStatus {
|
|
SUBMITTED
|
|
IN_REVIEW
|
|
CHANGES_REQUESTED
|
|
APPROVED
|
|
}
|
|
|
|
enum NotificationType {
|
|
ASSIGNMENT
|
|
STATUS_CHANGE
|
|
REVISION_SUBMITTED
|
|
REVISION_FEEDBACK
|
|
COMMENT
|
|
DEADLINE_APPROACHING
|
|
DEADLINE_OVERDUE
|
|
STAGE_UNBLOCKED
|
|
}
|
|
|
|
enum AssignmentRole {
|
|
LEAD
|
|
SUPPORT
|
|
}
|
|
|
|
// ─── Organization ───────────────────────────────────────
|
|
|
|
model Organization {
|
|
id String @id @default(cuid())
|
|
name String
|
|
domain String @unique
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
users User[]
|
|
projects Project[]
|
|
|
|
@@map("organizations")
|
|
}
|
|
|
|
// ─── Auth.js models ─────────────────────────────────────
|
|
|
|
model User {
|
|
id String @id @default(cuid())
|
|
name String?
|
|
email String @unique
|
|
emailVerified DateTime?
|
|
image String?
|
|
role Role @default(ARTIST)
|
|
|
|
organizationId String?
|
|
organization Organization? @relation(fields: [organizationId], references: [id])
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
accounts Account[]
|
|
sessions Session[]
|
|
assignments StageAssignment[]
|
|
comments Comment[]
|
|
notifications Notification[]
|
|
|
|
@@map("users")
|
|
}
|
|
|
|
model Account {
|
|
id String @id @default(cuid())
|
|
userId String
|
|
type String
|
|
provider String
|
|
providerAccountId String
|
|
refresh_token String? @db.Text
|
|
access_token String? @db.Text
|
|
expires_at Int?
|
|
token_type String?
|
|
scope String?
|
|
id_token String? @db.Text
|
|
session_state String?
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
@@unique([provider, providerAccountId])
|
|
@@map("accounts")
|
|
}
|
|
|
|
model Session {
|
|
id String @id @default(cuid())
|
|
sessionToken String @unique
|
|
userId String
|
|
expires DateTime
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
@@map("sessions")
|
|
}
|
|
|
|
model VerificationToken {
|
|
identifier String
|
|
token String
|
|
expires DateTime
|
|
|
|
@@unique([identifier, token])
|
|
@@map("verification_tokens")
|
|
}
|
|
|
|
// ─── Pipeline Templates (seed data) ────────────────────
|
|
|
|
model PipelineStageTemplate {
|
|
id String @id @default(cuid())
|
|
name String @unique
|
|
slug String @unique
|
|
order Int @unique
|
|
isCriticalGate Boolean @default(false)
|
|
isOptional Boolean @default(false)
|
|
description String?
|
|
|
|
dependsOn PipelineStageDependency[] @relation("DependsOnStage")
|
|
dependedBy PipelineStageDependency[] @relation("PrerequisiteStage")
|
|
|
|
deliverableStages DeliverableStage[]
|
|
|
|
@@map("pipeline_stage_templates")
|
|
}
|
|
|
|
model PipelineStageDependency {
|
|
id String @id @default(cuid())
|
|
stageId String
|
|
prerequisiteId String
|
|
|
|
stage PipelineStageTemplate @relation("DependsOnStage", fields: [stageId], references: [id])
|
|
prerequisite PipelineStageTemplate @relation("PrerequisiteStage", fields: [prerequisiteId], references: [id])
|
|
|
|
@@unique([stageId, prerequisiteId])
|
|
@@map("pipeline_stage_dependencies")
|
|
}
|
|
|
|
// ─── Project ────────────────────────────────────────────
|
|
|
|
model Project {
|
|
id String @id @default(cuid())
|
|
projectCode String @unique
|
|
name String
|
|
description String?
|
|
status ProjectStatus @default(ACTIVE)
|
|
priority Priority @default(MEDIUM)
|
|
startDate DateTime?
|
|
dueDate DateTime?
|
|
|
|
organizationId String
|
|
organization Organization @relation(fields: [organizationId], references: [id])
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
deliverables Deliverable[]
|
|
|
|
@@index([organizationId])
|
|
@@index([status])
|
|
@@map("projects")
|
|
}
|
|
|
|
// ─── Deliverable ────────────────────────────────────────
|
|
|
|
model Deliverable {
|
|
id String @id @default(cuid())
|
|
name String
|
|
status DeliverableStatus @default(NOT_STARTED)
|
|
priority Priority @default(MEDIUM)
|
|
dueDate DateTime?
|
|
notes String?
|
|
|
|
projectId String
|
|
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
stages DeliverableStage[]
|
|
|
|
@@index([projectId])
|
|
@@index([status])
|
|
@@map("deliverables")
|
|
}
|
|
|
|
// ─── Deliverable Stage (instance per deliverable) ───────
|
|
|
|
model DeliverableStage {
|
|
id String @id @default(cuid())
|
|
status StageStatus @default(BLOCKED)
|
|
revisionRound Int @default(0)
|
|
startDate DateTime?
|
|
completedDate DateTime?
|
|
dueDate DateTime?
|
|
notes String?
|
|
|
|
deliverableId String
|
|
deliverable Deliverable @relation(fields: [deliverableId], references: [id], onDelete: Cascade)
|
|
|
|
templateId String
|
|
template PipelineStageTemplate @relation(fields: [templateId], references: [id])
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
assignments StageAssignment[]
|
|
revisions Revision[]
|
|
comments Comment[]
|
|
|
|
@@unique([deliverableId, templateId])
|
|
@@index([deliverableId])
|
|
@@index([status])
|
|
@@map("deliverable_stages")
|
|
}
|
|
|
|
// ─── Stage Assignment ───────────────────────────────────
|
|
|
|
model StageAssignment {
|
|
id String @id @default(cuid())
|
|
role AssignmentRole? @default(LEAD)
|
|
|
|
deliverableStageId String
|
|
deliverableStage DeliverableStage @relation(fields: [deliverableStageId], references: [id], onDelete: Cascade)
|
|
|
|
userId String
|
|
user User @relation(fields: [userId], references: [id])
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
@@unique([deliverableStageId, userId])
|
|
@@index([userId])
|
|
@@map("stage_assignments")
|
|
}
|
|
|
|
// ─── Revision ───────────────────────────────────────────
|
|
|
|
model Revision {
|
|
id String @id @default(cuid())
|
|
roundNumber Int
|
|
status RevisionStatus @default(SUBMITTED)
|
|
feedbackNotes String?
|
|
internalNotes String?
|
|
attachments Json?
|
|
|
|
deliverableStageId String
|
|
deliverableStage DeliverableStage @relation(fields: [deliverableStageId], references: [id], onDelete: Cascade)
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@index([deliverableStageId])
|
|
@@map("revisions")
|
|
}
|
|
|
|
// ─── Comment ────────────────────────────────────────────
|
|
|
|
model Comment {
|
|
id String @id @default(cuid())
|
|
content String @db.Text
|
|
|
|
deliverableStageId String
|
|
deliverableStage DeliverableStage @relation(fields: [deliverableStageId], references: [id], onDelete: Cascade)
|
|
|
|
authorId String
|
|
author User @relation(fields: [authorId], references: [id])
|
|
|
|
parentId String?
|
|
parent Comment? @relation("CommentThread", fields: [parentId], references: [id])
|
|
replies Comment[] @relation("CommentThread")
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@index([deliverableStageId])
|
|
@@index([parentId])
|
|
@@map("comments")
|
|
}
|
|
|
|
// ─── Notification ───────────────────────────────────────
|
|
|
|
model Notification {
|
|
id String @id @default(cuid())
|
|
type NotificationType
|
|
title String
|
|
message String
|
|
link String?
|
|
isRead Boolean @default(false)
|
|
|
|
userId String
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
@@index([userId, isRead])
|
|
@@map("notifications")
|
|
}
|