My-Weekly-ToDo-List/prisma/schema.prisma
mARTin db00642c21 feat: Add Microsoft To-Do and Outlook Calendar integration
Adds full OAuth2 flow, bidirectional task sync, calendar event CRUD,
caching with background refresh, and shared token management for
Microsoft/Outlook services. Extracts common token refresh logic into
shared outlook-token.ts utility.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21 22:07:37 +01:00

232 lines
7.8 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
passwordHash String? // Optional for SSO users
name String?
image String?
emailVerified DateTime?
verifiedAt DateTime?
emailVerificationToken String?
emailVerificationExpires DateTime?
passwordResetToken String?
passwordResetExpires DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
timezone String @default("UTC")
autoRolling Boolean @default(false)
protectEventTimes Boolean @default(false)
language String @default("de")
dateFormat String @default("yyyy-MM-dd")
timeFormat String @default("24h")
startHour Int @default(8)
endHour Int @default(18)
showNextTask Boolean @default(false)
calendarEditMode Boolean @default(false)
focusTimerDuration Int @default(25)
focusBreakDuration Int @default(5)
showTimeGrid Boolean @default(true)
showSomeday Boolean @default(true)
showAllDayEvents Boolean @default(true)
showSchedule Boolean @default(true)
cellDuration Int @default(30)
viewStyle String @default("grid")
viewDays Int @default(7)
fontSize String @default("M") // "S", "M", "L"
goalFallbackType String @default("quote") // "quote" | "next_todo" | "default"
goalDefaultSentence String @default("goal of the week")
goalFontFamily String? @default("Inter")
goalFontSize String? @default("0.9rem")
goalFontWeight String? @default("500")
goalScope String @default("week") // "week" | "day"
headlineFont String @default("Inter")
headlineFontSize String? @default("1.25rem")
headlineFontWeight String? @default("900")
dateFontFamily String? @default("Inter")
dateFontSize String? @default("0.65rem")
dateFontWeight String? @default("400")
timeTaskFontFamily String? @default("Inter")
timeTaskFontSize String? @default("0.75rem")
timeTaskFontWeight String? @default("500")
bodyFont String @default("Inter")
taskFontFamily String? @default("Inter")
taskFontSize String? @default("0.9rem")
taskFontWeight String? @default("400")
eventFontFamily String? @default("Inter")
eventFontSize String? @default("0.85rem")
eventFontWeight String? @default("400")
fontWeight String @default("400") // Legacy/Generic
// Color Settings
weekdayColor String? @default("#888888")
dateColor String? @default("#888888")
taskColor String? @default("#333333")
todayHighlightColor String? @default("#f0fafa")
weekendColorSat String? @default("#666666")
weekendColorSun String? @default("#dc2626")
pastDayColor String? @default("#a6a6a7")
accounts Account[]
sessions Session[]
tasks Task[]
somedayLists SomedayList[]
calendarConnections CalendarConnection[]
cachedCalendarEvents CachedCalendarEvent[]
weeklyGoals WeeklyGoal[]
}
model Account {
id String @id @default(cuid())
userId String
type String
provider String
providerAccountId String
refresh_token String? @db.Text
access_token String? @db.Text
expires_at Int?
token_type String?
scope String?
id_token String? @db.Text
session_state String?
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@unique([provider, providerAccountId])
}
model Session {
id String @id @default(cuid())
sessionToken String @unique
userId String
expires DateTime
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
}
model VerificationToken {
identifier String
token String @unique
expires DateTime
@@unique([identifier, token])
}
model Task {
id String @id @default(cuid())
userId String
title String
description String?
markdownContent String? @db.Text
completed Boolean @default(false)
isRolling Boolean @default(false)
order Int @default(0)
dayOfWeek Int? // 0-6 for Sunday-Saturday (legacy/someday lists)
scheduledDate DateTime? // Actual date for the task
somedayListId String?
originalDate DateTime?
startTime String?
endTime String?
isRecurring Boolean @default(false)
recurrenceInterval Int? // Number of units between occurrences
recurrenceUnit String? // "days" or "weeks"
recurrenceTime String? // e.g. "09:00" - time for the recurring task
recurrenceEndDate DateTime? // Optional end date for recurrence
deletedAt DateTime? // Soft delete - null means active, set means trashed
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
somedayList SomedayList? @relation(fields: [somedayListId], references: [id], onDelete: SetNull)
// External Integration
externalId String?
externalProvider String? // "google" | "apple" | "outlook"
externalListId String?
lastSyncedAt DateTime?
@@index([userId, dayOfWeek])
@@index([userId, scheduledDate])
@@index([userId, somedayListId])
@@index([userId, externalId])
@@index([userId, deletedAt])
}
model SomedayList {
id String @id @default(cuid())
userId String
title String
order Int @default(0)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
tasks Task[]
@@index([userId])
}
model CalendarConnection {
id String @id @default(cuid())
userId String
provider String
accessToken String
refreshToken String?
expiresAt DateTime?
calendars Json? // Stores array of { id, title, isPrimary, selected }
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
cachedEvents CachedCalendarEvent[]
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
}
model CachedCalendarEvent {
id String @id @default(cuid())
userId String
externalId String
connectionId String
provider String // "google" | "apple" | "outlook"
calendarId String
calendarTitle String
calendarColor String?
title String
description String? @db.Text
location String?
startDateTime DateTime?
startDate String? // YYYY-MM-DD for all-day events
endDateTime DateTime?
endDate String? // YYYY-MM-DD for all-day events
weekStart DateTime
syncedAt DateTime @default(now())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
connection CalendarConnection @relation(fields: [connectionId], references: [id], onDelete: Cascade)
@@unique([userId, externalId, provider])
@@index([userId, startDateTime])
@@index([userId, startDate])
@@index([connectionId, weekStart])
}
model WeeklyGoal {
id String @id @default(cuid())
userId String
weekStart DateTime
text String @default("your goal of this week")
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@unique([userId, weekStart])
@@index([userId])
}