Add MP3 upload pipeline foundation
This commit is contained in:
@@ -7,8 +7,25 @@ datasource db {
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
model User {
|
||||
id String @id @default(uuid()) @db.Uuid
|
||||
slug String @unique
|
||||
displayName String @map("display_name")
|
||||
isDefault Boolean @default(false) @map("is_default")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
devices Device[]
|
||||
tracks Track[]
|
||||
audioAssets AudioAsset[]
|
||||
uploadSessions UploadSession[]
|
||||
libraryEvents LibraryEvent[]
|
||||
|
||||
@@map("users")
|
||||
}
|
||||
|
||||
model Device {
|
||||
id String @id @default(uuid()) @db.Uuid
|
||||
userId String @db.Uuid @map("user_id")
|
||||
platform DevicePlatform
|
||||
deviceName String @map("device_name")
|
||||
appVersion String @map("app_version")
|
||||
@@ -19,12 +36,15 @@ model Device {
|
||||
uploadSessions UploadSession[]
|
||||
syncCursor DeviceSyncCursor?
|
||||
audioAssets AudioAsset[]
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: Cascade)
|
||||
|
||||
@@index([userId])
|
||||
@@map("devices")
|
||||
}
|
||||
|
||||
model Track {
|
||||
id String @id @default(uuid()) @db.Uuid
|
||||
userId String @db.Uuid @map("user_id")
|
||||
primaryAudioAssetId String? @unique @db.Uuid @map("primary_audio_asset_id")
|
||||
artworkAssetId String? @unique @db.Uuid @map("artwork_asset_id")
|
||||
title String
|
||||
@@ -43,14 +63,17 @@ model Track {
|
||||
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")
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: Cascade)
|
||||
|
||||
@@index([userId])
|
||||
@@map("tracks")
|
||||
}
|
||||
|
||||
model AudioAsset {
|
||||
id String @id @default(uuid()) @db.Uuid
|
||||
userId String @db.Uuid @map("user_id")
|
||||
trackId String? @db.Uuid @map("track_id")
|
||||
sha256 String @unique
|
||||
sha256 String
|
||||
storageKey String @unique @map("storage_key")
|
||||
originalFilename String @map("original_filename")
|
||||
mimeType String @map("mime_type")
|
||||
@@ -65,7 +88,10 @@ model AudioAsset {
|
||||
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)
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: Cascade)
|
||||
|
||||
@@unique([userId, sha256])
|
||||
@@index([userId])
|
||||
@@map("audio_assets")
|
||||
}
|
||||
|
||||
@@ -85,28 +111,39 @@ model ArtworkAsset {
|
||||
|
||||
model UploadSession {
|
||||
id String @id @default(uuid()) @db.Uuid
|
||||
userId String @db.Uuid @map("user_id")
|
||||
deviceId String @db.Uuid @map("device_id")
|
||||
trackId String? @db.Uuid @map("track_id")
|
||||
audioAssetId String? @db.Uuid @map("audio_asset_id")
|
||||
expectedSha256 String @map("expected_sha256")
|
||||
originalFilename String @map("original_filename")
|
||||
expectedSizeBytes BigInt @map("expected_size_bytes")
|
||||
receivedBytes BigInt @default(0) @map("received_bytes")
|
||||
tempStoragePath String @map("temp_storage_path")
|
||||
status UploadSessionStatus @default(PENDING)
|
||||
completedAt DateTime? @map("completed_at")
|
||||
finalizedAt DateTime? @map("finalized_at")
|
||||
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)
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: Cascade)
|
||||
|
||||
@@index([userId])
|
||||
@@map("upload_sessions")
|
||||
}
|
||||
|
||||
model LibraryEvent {
|
||||
id BigInt @id @default(autoincrement())
|
||||
userId String @db.Uuid @map("user_id")
|
||||
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")
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: Cascade)
|
||||
|
||||
@@index([userId])
|
||||
@@map("library_events")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user