qia-server/prisma/schema.prisma
ddshi 96da6b6e42 feat: 添加priority字段支持
- Event模型添加priority字段
- routes/events.ts支持priority的创建和更新
- Prisma schema同步更新
- 添加数据库自动迁移

🤖 Generated with Claude Code
2026-02-05 17:52:33 +08:00

90 lines
2.5 KiB
Plaintext

// 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 = "sqlite"
url = env("DATABASE_URL")
}
// User model
model User {
id String @id @default(uuid())
email String @unique
password_hash String
nickname String?
created_at DateTime @default(now())
updated_at DateTime @updatedAt
// Relations
events Event[]
notes Note[]
conversations AICoachConversation[]
@@map("users")
}
// Event model (for both Anniversary and Reminder)
model Event {
id String @id @default(uuid())
user_id String
type String // 'anniversary' | 'reminder' (String for SQLite)
title String
content String? // Only for reminders
date DateTime // For anniversaries: the date; For reminders: the reminder date
is_lunar Boolean @default(false)
repeat_type String @default("none") // 'yearly' | 'monthly' | 'none' (String for SQLite)
is_holiday Boolean @default(false) // Only for anniversaries
is_completed Boolean @default(false) // Only for reminders
priority String @default("none") // 'none' | 'red' | 'green' | 'yellow' (String for SQLite)
created_at DateTime @default(now())
updated_at DateTime @updatedAt
// Relations
user User @relation(fields: [user_id], references: [id], onDelete: Cascade)
@@index([user_id])
@@index([type])
@@index([date])
@@map("events")
}
// Note model (for quick notes)
model Note {
id String @id @default(uuid())
user_id String
content String // HTML content from rich text editor
created_at DateTime @default(now())
updated_at DateTime @updatedAt
// Relations
user User @relation(fields: [user_id], references: [id], onDelete: Cascade)
// One note per user (based on PRD - 便签编辑区)
@@unique([user_id])
@@map("notes")
}
// AI Conversation model
model AICoachConversation {
id String @id @default(uuid())
user_id String
message String
response String
parsed_data String? // AI parsed event data (JSON string for SQLite)
created_at DateTime @default(now())
// Relations
user User @relation(fields: [user_id], references: [id], onDelete: Cascade)
@@index([user_id])
@@map("ai_coach_conversations")
}
// Note: Using String types instead of enums for SQLite compatibility
// Event type values: 'anniversary' | 'reminder'
// Repeat type values: 'yearly' | 'monthly' | 'none'