151 lines
5.3 KiB
Plaintext
151 lines
5.3 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
model Device {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
platform DevicePlatform
|
|
deviceName String @map("device_name")
|
|
appVersion String @map("app_version")
|
|
installTokenHash String @map("install_token_hash")
|
|
lastSeenAt DateTime @map("last_seen_at")
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
uploadSessions UploadSession[]
|
|
syncCursor DeviceSyncCursor?
|
|
audioAssets AudioAsset[]
|
|
|
|
@@map("devices")
|
|
}
|
|
|
|
model Track {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
primaryAudioAssetId String? @unique @db.Uuid @map("primary_audio_asset_id")
|
|
artworkAssetId String? @unique @db.Uuid @map("artwork_asset_id")
|
|
title String
|
|
artist String
|
|
album String?
|
|
albumArtist String? @map("album_artist")
|
|
genre String?
|
|
discNumber Int? @map("disc_number")
|
|
trackNumber Int? @map("track_number")
|
|
year Int?
|
|
durationMs Int? @map("duration_ms")
|
|
status TrackStatus @default(ACTIVE)
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
deletedAt DateTime? @map("deleted_at")
|
|
primaryAudioAsset AudioAsset? @relation("PrimaryAudioAsset", fields: [primaryAudioAssetId], references: [id], onDelete: SetNull, onUpdate: Cascade)
|
|
artworkAsset ArtworkAsset? @relation("TrackArtwork", fields: [artworkAssetId], references: [id], onDelete: SetNull, onUpdate: Cascade)
|
|
audioAssets AudioAsset[] @relation("TrackAudioAssets")
|
|
|
|
@@map("tracks")
|
|
}
|
|
|
|
model AudioAsset {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
trackId String? @db.Uuid @map("track_id")
|
|
sha256 String @unique
|
|
storageKey String @unique @map("storage_key")
|
|
originalFilename String @map("original_filename")
|
|
mimeType String @map("mime_type")
|
|
fileExtension String @map("file_extension")
|
|
fileSizeBytes BigInt @map("file_size_bytes")
|
|
bitRateKbps Int? @map("bit_rate_kbps")
|
|
sampleRateHz Int? @map("sample_rate_hz")
|
|
channels Int?
|
|
durationMs Int? @map("duration_ms")
|
|
sourceDeviceId String? @db.Uuid @map("source_device_id")
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
track Track? @relation("TrackAudioAssets", fields: [trackId], references: [id], onDelete: SetNull, onUpdate: Cascade)
|
|
primaryForTrack Track? @relation("PrimaryAudioAsset")
|
|
sourceDevice Device? @relation(fields: [sourceDeviceId], references: [id], onDelete: SetNull, onUpdate: Cascade)
|
|
|
|
@@map("audio_assets")
|
|
}
|
|
|
|
model ArtworkAsset {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
sha256 String @unique
|
|
storageKey String @unique @map("storage_key")
|
|
mimeType String @map("mime_type")
|
|
width Int?
|
|
height Int?
|
|
fileSizeBytes BigInt @map("file_size_bytes")
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
track Track? @relation("TrackArtwork")
|
|
|
|
@@map("artwork_assets")
|
|
}
|
|
|
|
model UploadSession {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
deviceId String @db.Uuid @map("device_id")
|
|
expectedSha256 String @map("expected_sha256")
|
|
expectedSizeBytes BigInt @map("expected_size_bytes")
|
|
receivedBytes BigInt @default(0) @map("received_bytes")
|
|
tempStoragePath String @map("temp_storage_path")
|
|
status UploadSessionStatus @default(PENDING)
|
|
expiresAt DateTime @map("expires_at")
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
device Device @relation(fields: [deviceId], references: [id], onDelete: Cascade, onUpdate: Cascade)
|
|
|
|
@@map("upload_sessions")
|
|
}
|
|
|
|
model LibraryEvent {
|
|
id BigInt @id @default(autoincrement())
|
|
entityType EntityType @map("entity_type")
|
|
entityId String @db.Uuid @map("entity_id")
|
|
action EventAction
|
|
payloadVersion Int @default(1) @map("payload_version")
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
@@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)
|
|
|
|
@@map("device_sync_cursors")
|
|
}
|
|
|
|
enum DevicePlatform {
|
|
MACOS
|
|
IPHONE
|
|
}
|
|
|
|
enum TrackStatus {
|
|
ACTIVE
|
|
DELETED
|
|
}
|
|
|
|
enum UploadSessionStatus {
|
|
PENDING
|
|
READY_TO_UPLOAD
|
|
COMPLETED
|
|
FAILED
|
|
}
|
|
|
|
enum EntityType {
|
|
TRACK
|
|
AUDIO_ASSET
|
|
ARTWORK_ASSET
|
|
}
|
|
|
|
enum EventAction {
|
|
CREATED
|
|
UPDATED
|
|
DELETED
|
|
}
|