generated from fahricansecer/boilerplate-be
Initial commit
This commit is contained in:
314
prisma/schema.prisma
Normal file
314
prisma/schema.prisma
Normal file
@@ -0,0 +1,314 @@
|
||||
// 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 = "postgresql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// Core Models
|
||||
// ============================================
|
||||
|
||||
model User {
|
||||
id String @id @default(uuid())
|
||||
email String @unique
|
||||
password String
|
||||
firstName String?
|
||||
lastName String?
|
||||
isActive Boolean @default(true)
|
||||
|
||||
// Relations
|
||||
roles UserRole[]
|
||||
refreshTokens RefreshToken[]
|
||||
projects ScriptProject[]
|
||||
|
||||
// Multi-tenancy (optional)
|
||||
tenantId String?
|
||||
tenant Tenant? @relation(fields: [tenantId], references: [id])
|
||||
|
||||
// Timestamps & Soft Delete
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
deletedAt DateTime?
|
||||
|
||||
@@index([email])
|
||||
@@index([tenantId])
|
||||
}
|
||||
|
||||
model Role {
|
||||
id String @id @default(uuid())
|
||||
name String @unique
|
||||
description String?
|
||||
isSystem Boolean @default(false)
|
||||
|
||||
// Relations
|
||||
users UserRole[]
|
||||
permissions RolePermission[]
|
||||
|
||||
// Timestamps & Soft Delete
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
deletedAt DateTime?
|
||||
|
||||
@@index([name])
|
||||
}
|
||||
|
||||
model Permission {
|
||||
id String @id @default(uuid())
|
||||
name String @unique
|
||||
description String?
|
||||
resource String // e.g., "users", "posts"
|
||||
action String // e.g., "create", "read", "update", "delete"
|
||||
|
||||
// Relations
|
||||
roles RolePermission[]
|
||||
|
||||
// Timestamps
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@unique([resource, action])
|
||||
@@index([resource])
|
||||
}
|
||||
|
||||
// Many-to-many: User <-> Role
|
||||
model UserRole {
|
||||
id String @id @default(uuid())
|
||||
userId String
|
||||
roleId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
role Role @relation(fields: [roleId], references: [id], onDelete: Cascade)
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
@@unique([userId, roleId])
|
||||
@@index([userId])
|
||||
@@index([roleId])
|
||||
}
|
||||
|
||||
// Many-to-many: Role <-> Permission
|
||||
model RolePermission {
|
||||
id String @id @default(uuid())
|
||||
roleId String
|
||||
permissionId String
|
||||
role Role @relation(fields: [roleId], references: [id], onDelete: Cascade)
|
||||
permission Permission @relation(fields: [permissionId], references: [id], onDelete: Cascade)
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
@@unique([roleId, permissionId])
|
||||
@@index([roleId])
|
||||
@@index([permissionId])
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// Authentication
|
||||
// ============================================
|
||||
|
||||
model RefreshToken {
|
||||
id String @id @default(uuid())
|
||||
token String @unique
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
expiresAt DateTime
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
@@index([token])
|
||||
@@index([userId])
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// Multi-tenancy (Optional)
|
||||
// ============================================
|
||||
|
||||
model Tenant {
|
||||
id String @id @default(uuid())
|
||||
name String
|
||||
slug String @unique
|
||||
isActive Boolean @default(true)
|
||||
|
||||
// Relations
|
||||
users User[]
|
||||
|
||||
// Timestamps & Soft Delete
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
deletedAt DateTime?
|
||||
|
||||
@@index([slug])
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// i18n / Translations (Optional - DB driven)
|
||||
// ============================================
|
||||
|
||||
model Translation {
|
||||
id String @id @default(uuid())
|
||||
key String
|
||||
locale String // e.g., "en", "tr", "de"
|
||||
value String
|
||||
namespace String @default("common") // e.g., "common", "errors", "validation"
|
||||
|
||||
// Timestamps
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@unique([key, locale, namespace])
|
||||
@@index([key])
|
||||
@@index([locale])
|
||||
@@index([namespace])
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// SkriptAI Models
|
||||
// ============================================
|
||||
|
||||
model ScriptProject {
|
||||
id String @id @default(uuid())
|
||||
userId String?
|
||||
topic String
|
||||
contentType String // ContentFormat enum value
|
||||
targetAudience String[] // Array of TargetAudience values
|
||||
speechStyle String[] // Array of SpeechStyle values
|
||||
targetDuration String
|
||||
userNotes String? @db.Text
|
||||
tone String?
|
||||
language String @default("tr")
|
||||
logline String? @db.Text
|
||||
highConcept String? @db.Text
|
||||
includeInterviews Boolean @default(false)
|
||||
|
||||
// SEO Data (stored as JSON)
|
||||
seoTitle String?
|
||||
seoDescription String? @db.Text
|
||||
seoTags String[]
|
||||
thumbnailIdeas String[]
|
||||
|
||||
// Analysis Results (stored as JSON)
|
||||
neuroAnalysis Json?
|
||||
youtubeAudit Json?
|
||||
postProduction Json?
|
||||
commercialBrief Json?
|
||||
|
||||
// Timestamps & Soft Delete
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
deletedAt DateTime?
|
||||
|
||||
// Relations
|
||||
user User? @relation(fields: [userId], references: [id])
|
||||
segments ScriptSegment[]
|
||||
sources ResearchSource[]
|
||||
characters CharacterProfile[]
|
||||
briefItems BriefItem[]
|
||||
visualAssets VisualAsset[]
|
||||
|
||||
@@index([userId])
|
||||
@@index([topic])
|
||||
}
|
||||
|
||||
model ScriptSegment {
|
||||
id String @id @default(uuid())
|
||||
projectId String
|
||||
segmentType String // Hook, Intro, Body, Ad/Sponsor, CTA, Outro, Scene, Dialogue, Section, Headline
|
||||
timeStart String
|
||||
duration String
|
||||
visualDescription String? @db.Text
|
||||
narratorScript String? @db.Text
|
||||
editorNotes String? @db.Text
|
||||
generalNotes String? @db.Text
|
||||
audioCues String?
|
||||
onScreenText String?
|
||||
stockQuery String?
|
||||
videoPrompt String? @db.Text
|
||||
imagePrompt String? @db.Text
|
||||
citationIndexes Int[]
|
||||
generatedImageUrl String?
|
||||
sortOrder Int @default(0)
|
||||
|
||||
// Timestamps
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
// Relations
|
||||
project ScriptProject @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@index([projectId])
|
||||
@@index([sortOrder])
|
||||
}
|
||||
|
||||
model ResearchSource {
|
||||
id String @id @default(uuid())
|
||||
projectId String
|
||||
title String
|
||||
url String
|
||||
snippet String? @db.Text
|
||||
type String // article, video, interview, academic, book, document
|
||||
selected Boolean @default(true)
|
||||
isNew Boolean @default(false)
|
||||
|
||||
// Timestamps
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
// Relations
|
||||
project ScriptProject @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@index([projectId])
|
||||
}
|
||||
|
||||
model CharacterProfile {
|
||||
id String @id @default(uuid())
|
||||
projectId String
|
||||
name String
|
||||
role String // Protagonist, Antagonist, Guide/Mentor, Sidekick, Narrator
|
||||
values String? @db.Text
|
||||
traits String? @db.Text
|
||||
mannerisms String? @db.Text
|
||||
|
||||
// Timestamps
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
// Relations
|
||||
project ScriptProject @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@index([projectId])
|
||||
}
|
||||
|
||||
model BriefItem {
|
||||
id String @id @default(uuid())
|
||||
projectId String
|
||||
question String @db.Text
|
||||
answer String @db.Text
|
||||
sortOrder Int @default(0)
|
||||
|
||||
// Timestamps
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
// Relations
|
||||
project ScriptProject @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@index([projectId])
|
||||
}
|
||||
|
||||
model VisualAsset {
|
||||
id String @id @default(uuid())
|
||||
projectId String
|
||||
url String
|
||||
desc String?
|
||||
selected Boolean @default(true)
|
||||
|
||||
// Timestamps
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
// Relations
|
||||
project ScriptProject @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@index([projectId])
|
||||
}
|
||||
Reference in New Issue
Block a user