// 개발 환경에서는 SQLite를 사용합니다. // 운영 환경에서 MySQL로 전환할 때는 provider와 DATABASE_URL만 변경하고 // `prisma migrate dev`로 마이그레이션을 다시 생성하세요. generator client { provider = "prisma-client-js" } datasource db { provider = "sqlite" url = env("DATABASE_URL") } model AdminUser { id String @id @default(cuid()) loginId String @unique passwordHash String name String role String @default("ADMIN") // ADMIN | EDITOR totpSecret String? lastLoginAt DateTime? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt posts Post[] auditLogs AuditLog[] } model Post { id Int @id @default(autoincrement()) type String // NOTICE | ARCHIVE category String? title String content String isPinned Boolean @default(false) status String @default("PUBLISHED") // DRAFT | PUBLISHED viewCount Int @default(0) authorId String? author AdminUser? @relation(fields: [authorId], references: [id], onDelete: SetNull) publishedAt DateTime @default(now()) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt attachments Attachment[] @@index([type, status, publishedAt]) @@index([type, category]) } model Attachment { id Int @id @default(autoincrement()) postId Int? post Post? @relation(fields: [postId], references: [id], onDelete: Cascade) originalName String storageKey String @unique mimeType String size Int downloadCount Int @default(0) createdAt DateTime @default(now()) @@index([postId]) } model Inquiry { id Int @id @default(autoincrement()) name String email String phone String? title String content String consent Boolean @default(false) status String @default("NEW") // NEW | IN_PROGRESS | DONE ip String? createdAt DateTime @default(now()) @@index([status, createdAt]) } model AuditLog { id Int @id @default(autoincrement()) adminId String? admin AdminUser? @relation(fields: [adminId], references: [id], onDelete: SetNull) action String targetType String? targetId String? ip String? createdAt DateTime @default(now()) @@index([createdAt]) } model Setting { key String @id value String updatedAt DateTime @updatedAt }