Initial commit - EENE Dashboard
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
193
backend/prisma/schema.prisma
Normal file
193
backend/prisma/schema.prisma
Normal file
@@ -0,0 +1,193 @@
|
||||
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?
|
||||
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
|
||||
content String
|
||||
updatedBy String
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
task Task @relation(fields: [taskId], references: [id], onDelete: Cascade)
|
||||
author User @relation(fields: [updatedBy], references: [id])
|
||||
|
||||
@@index([taskId])
|
||||
@@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
|
||||
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)
|
||||
uploader User @relation(fields: [uploadedBy], references: [id])
|
||||
|
||||
@@index([taskId])
|
||||
@@map("files")
|
||||
}
|
||||
|
||||
// ─── 마일스톤 (프로세스 단계) ─────────────────────────────────
|
||||
|
||||
model Milestone {
|
||||
id String @id @default(cuid())
|
||||
taskId String
|
||||
title String
|
||||
description String?
|
||||
dueDate DateTime?
|
||||
completedAt DateTime?
|
||||
order Int @default(0)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
task Task @relation(fields: [taskId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@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")
|
||||
}
|
||||
Reference in New Issue
Block a user