211 lines
6.1 KiB
Plaintext
211 lines
6.1 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
// ─── 사용자 ──────────────────────────────────────────────────
|
|
|
|
model User {
|
|
id String @id @default(cuid())
|
|
email String @unique
|
|
password String
|
|
name String
|
|
role Role @default(MEMBER)
|
|
department String?
|
|
isActive Boolean @default(true)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
createdTasks Task[] @relation("CreatedTasks")
|
|
assignedTasks Task[] @relation("AssignedTasks")
|
|
taskDetails TaskDetail[]
|
|
uploadedFiles File[]
|
|
auditLogs AuditLog[]
|
|
|
|
@@map("users")
|
|
}
|
|
|
|
enum Role {
|
|
ADMIN
|
|
MANAGER
|
|
MEMBER
|
|
}
|
|
|
|
// ─── 업무 ────────────────────────────────────────────────────
|
|
|
|
model Task {
|
|
id String @id @default(cuid())
|
|
title String
|
|
description String?
|
|
status TaskStatus @default(TODO)
|
|
priority Priority @default(MEDIUM)
|
|
quarter String // 예: "2026-Q2"
|
|
category String?
|
|
section String? // HR | 운영관리
|
|
tag String? // Growth | Policy | Performance | Culture | Asset | Space | Safety | Environment
|
|
taskType String? // 상시업무 | 프로젝트
|
|
progress Int @default(0)
|
|
issueNote String?
|
|
startDate DateTime?
|
|
dueDate DateTime?
|
|
showDate Boolean @default(true)
|
|
showDescription Boolean @default(true)
|
|
showStatus Boolean @default(true)
|
|
showIssue Boolean @default(true)
|
|
showProgress Boolean @default(true)
|
|
keywords String?
|
|
creatorId String
|
|
assigneeId String?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
creator User @relation("CreatedTasks", fields: [creatorId], references: [id])
|
|
assignee User? @relation("AssignedTasks", fields: [assigneeId], references: [id])
|
|
details TaskDetail[]
|
|
kpiMetrics KpiMetric[]
|
|
files File[]
|
|
milestones Milestone[]
|
|
|
|
@@index([quarter])
|
|
@@index([status])
|
|
@@index([assigneeId])
|
|
@@index([section])
|
|
@@map("tasks")
|
|
}
|
|
|
|
enum TaskStatus {
|
|
TODO
|
|
IN_PROGRESS
|
|
REVIEW
|
|
DONE
|
|
CANCELLED
|
|
}
|
|
|
|
enum Priority {
|
|
LOW
|
|
MEDIUM
|
|
HIGH
|
|
URGENT
|
|
}
|
|
|
|
// ─── 업무 상세 / 진행 기록 ────────────────────────────────────
|
|
|
|
model TaskDetail {
|
|
id String @id @default(cuid())
|
|
taskId String
|
|
milestoneId String?
|
|
content String
|
|
updatedBy String
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
task Task @relation(fields: [taskId], references: [id], onDelete: Cascade)
|
|
milestone Milestone? @relation(fields: [milestoneId], references: [id], onDelete: Cascade)
|
|
author User @relation(fields: [updatedBy], references: [id])
|
|
|
|
@@index([taskId])
|
|
@@index([milestoneId])
|
|
@@map("task_details")
|
|
}
|
|
|
|
// ─── KPI 지표 ────────────────────────────────────────────────
|
|
|
|
model KpiMetric {
|
|
id String @id @default(cuid())
|
|
taskId String
|
|
quarter String
|
|
target Float
|
|
actual Float @default(0)
|
|
unit String?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
task Task @relation(fields: [taskId], references: [id], onDelete: Cascade)
|
|
|
|
@@index([quarter])
|
|
@@map("kpi_metrics")
|
|
}
|
|
|
|
// ─── 파일 ────────────────────────────────────────────────────
|
|
|
|
model File {
|
|
id String @id @default(cuid())
|
|
taskId String
|
|
milestoneId String?
|
|
filename String // 저장된 파일명 (UUID)
|
|
originalName String // 원본 파일명
|
|
mimetype String
|
|
size Int
|
|
path String
|
|
uploadedBy String
|
|
createdAt DateTime @default(now())
|
|
|
|
task Task @relation(fields: [taskId], references: [id], onDelete: Cascade)
|
|
milestone Milestone? @relation(fields: [milestoneId], references: [id], onDelete: SetNull)
|
|
uploader User @relation(fields: [uploadedBy], references: [id])
|
|
|
|
@@index([taskId])
|
|
@@index([milestoneId])
|
|
@@map("files")
|
|
}
|
|
|
|
// ─── 마일스톤 (프로세스 단계) ─────────────────────────────────
|
|
|
|
model Milestone {
|
|
id String @id @default(cuid())
|
|
taskId String
|
|
title String
|
|
description String?
|
|
startDate DateTime?
|
|
dueDate DateTime?
|
|
progress Int @default(0)
|
|
links String? // JSON: [{ "label": string, "url": string }]
|
|
completedAt DateTime?
|
|
order Int @default(0)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
task Task @relation(fields: [taskId], references: [id], onDelete: Cascade)
|
|
details TaskDetail[]
|
|
files File[]
|
|
|
|
@@index([taskId])
|
|
@@map("milestones")
|
|
}
|
|
|
|
// ─── 컬럼 설정 ───────────────────────────────────────────────
|
|
|
|
model ColumnConfig {
|
|
key String @id // "HR" | "운영관리"
|
|
title String
|
|
titleEn String?
|
|
subtitle String?
|
|
cardOrder String? // JSON 배열: task id 순서
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@map("column_configs")
|
|
}
|
|
|
|
// ─── 감사 로그 ───────────────────────────────────────────────
|
|
|
|
model AuditLog {
|
|
id String @id @default(cuid())
|
|
userId String
|
|
action String // CREATE, UPDATE, DELETE, LOGIN 등
|
|
entity String // Task, User, File 등
|
|
entityId String?
|
|
details Json?
|
|
ipAddress String?
|
|
createdAt DateTime @default(now())
|
|
|
|
user User @relation(fields: [userId], references: [id])
|
|
|
|
@@index([userId])
|
|
@@index([createdAt])
|
|
@@map("audit_logs")
|
|
}
|