Implement incremental sync and offline recovery
This commit is contained in:
@@ -12,6 +12,7 @@ model User {
|
||||
slug String @unique
|
||||
displayName String @map("display_name")
|
||||
isDefault Boolean @default(false) @map("is_default")
|
||||
libraryCursor BigInt @default(0) @map("library_cursor")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
devices Device[]
|
||||
@@ -20,6 +21,7 @@ model User {
|
||||
artworkAssets ArtworkAsset[]
|
||||
uploadSessions UploadSession[]
|
||||
libraryEvents LibraryEvent[]
|
||||
syncCursors DeviceSyncCursor[]
|
||||
|
||||
@@map("users")
|
||||
}
|
||||
@@ -145,24 +147,30 @@ model UploadSession {
|
||||
model LibraryEvent {
|
||||
id BigInt @id @default(autoincrement())
|
||||
userId String @db.Uuid @map("user_id")
|
||||
cursor BigInt
|
||||
entityType EntityType @map("entity_type")
|
||||
entityId String @db.Uuid @map("entity_id")
|
||||
action EventAction
|
||||
payload Json
|
||||
payloadVersion Int @default(1) @map("payload_version")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: Cascade)
|
||||
|
||||
@@index([userId])
|
||||
@@unique([userId, cursor])
|
||||
@@index([userId, cursor])
|
||||
@@map("library_events")
|
||||
}
|
||||
|
||||
model DeviceSyncCursor {
|
||||
deviceId String @id @db.Uuid @map("device_id")
|
||||
lastEventId BigInt @default(0) @map("last_event_id")
|
||||
lastFullSyncAt DateTime? @map("last_full_sync_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
device Device @relation(fields: [deviceId], references: [id], onDelete: Cascade, onUpdate: Cascade)
|
||||
deviceId String @id @db.Uuid @map("device_id")
|
||||
userId String @db.Uuid @map("user_id")
|
||||
cursor BigInt @default(0)
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
device Device @relation(fields: [deviceId], references: [id], onDelete: Cascade, onUpdate: Cascade)
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: Cascade)
|
||||
|
||||
@@index([userId])
|
||||
@@map("device_sync_cursors")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user