feat(asset): decouple logical assets from physical storage with StorageKey and implement O(1) copy

This commit is contained in:
yiling
2026-05-25 00:52:45 +08:00
parent c5fba746be
commit 5dc3bdb38e
33 changed files with 2203 additions and 273 deletions
+13 -1
View File
@@ -347,7 +347,6 @@ model Asset {
id String @id @default(ulid())
name String @default("")
nameNgram String[] @default([]) @map("name_ngram")
key String?
type AssetType
mediaType String? @map("media_type")
fileCount Int @default(0) @map("file_count")
@@ -370,6 +369,9 @@ model Asset {
target Asset? @relation("SymlinkTarget", fields: [targetId], references: [id])
symlinks Asset[] @relation("SymlinkTarget")
storageKeyId String? @map("storage_key_id")
storageKey StorageKey? @relation(fields: [storageKeyId], references: [id])
metadataValues AssetMetadataValue[] @relation("AssetToMetadataValues")
creatorId String? @map("creator_id")
@@ -403,6 +405,16 @@ model Asset {
@@unique([parentId, targetId], name: "parentIdTargetId")
}
model StorageKey {
id String @id @default(ulid())
key String @unique
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
assets Asset[]
@@map("storage_keys")
}
model AssetMetadataValue {
id String @id @default(ulid())
assetId String @map("asset_id")