69 lines
2.6 KiB
Plaintext
69 lines
2.6 KiB
Plaintext
// VA-P28f: personal calendars for HiveGrid's tenant-less admin sales workspace.
|
|
//
|
|
// OAuth credentials remain exclusively in AdminDataConnection. Calendar sync
|
|
// stores provider cursors plus anonymous busy intervals; titles, descriptions
|
|
// and attendee lists from unrelated external events are deliberately discarded.
|
|
|
|
enum AdminCalendarConnectionStatus {
|
|
active
|
|
degraded
|
|
reconnect_required
|
|
revoked
|
|
}
|
|
|
|
enum AdminCalendarSyncStatus {
|
|
pending
|
|
syncing
|
|
active
|
|
recovery_required
|
|
failed
|
|
}
|
|
|
|
model AdminCalendarConnection {
|
|
id String @id @default(cuid())
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
archivedAt DateTime?
|
|
adminUserId String
|
|
dataConnectionId String @unique
|
|
externalCalendarId String
|
|
externalCalendarLabel String?
|
|
timeZone String
|
|
status AdminCalendarConnectionStatus @default(active)
|
|
lastSyncAt DateTime?
|
|
lastErrorCode String?
|
|
healthMessageKey String?
|
|
webhookExpiresAt DateTime?
|
|
|
|
adminUser AdminUser @relation(fields: [adminUserId], references: [id], onDelete: Restrict)
|
|
dataConnection AdminDataConnection @relation(fields: [dataConnectionId], references: [id], onDelete: Restrict)
|
|
syncCursors AdminCalendarSyncCursor[]
|
|
bookings AdminBooking[]
|
|
|
|
@@unique([adminUserId, externalCalendarId], name: "admin_calendar_owner_external_key")
|
|
@@index([adminUserId, status, archivedAt], name: "admin_calendar_owner_status_idx")
|
|
@@index([status, webhookExpiresAt], name: "admin_calendar_webhook_renewal_idx")
|
|
}
|
|
|
|
model AdminCalendarSyncCursor {
|
|
id String @id @default(cuid())
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
adminUserId String
|
|
calendarConnectionId String
|
|
externalCalendarId String
|
|
cursorToken String?
|
|
deltaLink String?
|
|
busyIntervals Json @default("[]")
|
|
status AdminCalendarSyncStatus @default(pending)
|
|
lastFullSyncAt DateTime?
|
|
lastIncrementalSyncAt DateTime?
|
|
recoveryRequestedAt DateTime?
|
|
lastErrorCode String?
|
|
|
|
calendarConnection AdminCalendarConnection @relation(fields: [calendarConnectionId], references: [id], onDelete: Cascade)
|
|
|
|
@@unique([calendarConnectionId, externalCalendarId], name: "admin_calendar_cursor_external_key")
|
|
@@index([adminUserId, status, updatedAt], name: "admin_calendar_cursor_owner_status_idx")
|
|
}
|