🐛 Fix migrate has no value

This commit is contained in:
LittleSheep 2025-06-02 20:52:03 +08:00
parent 2691c5d9ac
commit 5487b4e607

View File

@ -43,16 +43,18 @@ public class FileReferenceMigrationService(AppDatabase db)
.ToDictionary(g => g.Key, g => g.ToList()); .ToDictionary(g => g.Key, g => g.ToList());
var fileReferences = posts.SelectMany(post => var fileReferences = posts.SelectMany(post =>
attachmentsDict[post.Id].Select(attachment => attachmentsDict.TryGetValue(post.Id, out var value)
new CloudFileReference ? value.Select(attachment =>
{ new CloudFileReference
FileId = attachment.Id, {
File = attachment, FileId = attachment.Id,
Usage = "post", File = attachment,
ResourceId = post.Id.ToString(), Usage = "post",
CreatedAt = SystemClock.Instance.GetCurrentInstant(), ResourceId = post.Id.ToString(),
UpdatedAt = SystemClock.Instance.GetCurrentInstant() CreatedAt = SystemClock.Instance.GetCurrentInstant(),
}) UpdatedAt = SystemClock.Instance.GetCurrentInstant()
})
: []
) )
.ToList(); .ToList();