qia-server/prisma/schema.prisma
ddshi 15918f163c fix: 修复 reminder_times 处理和 UTC 时间存储
- server: 处理 reminder_times 更新时支持 null 值
- client: 统一使用 UTC 格式存储日期时间
- client: 修复 calculateNextDueDate 使用 UTC 时间计算
- client: 修复 calculateReminderTimes 使用 UTC 时间计算
- client: 修复 getReminderValueFromTimes 反推提醒选项
- client: 重写 createNextRecurringEventData 根据新日期重新计算 reminder_times
- 解决用户设置"14:00"显示"22:00"等时区问题
- 解决重复提醒自动创建时继承 reminder_times 问题

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-10 11:07:21 +08:00

93 lines
2.7 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)
repeat_interval Int? // Weekly interval (only for weekly type)
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)
next_reminder_date DateTime? // Next reminder date (calculated)
reminder_times String? // JSON array of reminder timestamps (ISO strings)
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'