fix: backfill postgres upload result defaults

This commit is contained in:
2026-04-30 12:29:49 +08:00
parent 723bd3945e
commit 39404560cc
2 changed files with 7 additions and 5 deletions
@@ -490,13 +490,13 @@ public sealed class SqliteToPostgresMigrationService
SetParameter(command, "@DanmakuMessageCount", reader.GetInt32(i++));
SetParameter(command, "@FinalStatus", reader.GetInt32(i++));
SetParameter(command, "@ErrorMessage", GetNullableString(reader, i++));
SetParameter(command, "@UploadStatus", reader.GetInt32(i++));
SetParameter(command, "@UploadStatus", GetNullableInt32(reader, i++) ?? 0);
SetParameter(command, "@LastUploadProvider", GetNullableString(reader, i++));
SetParameter(command, "@RemoteVideoPath", GetNullableString(reader, i++));
SetParameter(command, "@RemoteDanmakuPath", GetNullableString(reader, i++));
SetParameter(command, "@LastUploadedAt", GetNullableDateTimeOffset(reader, i++));
SetParameter(command, "@UploadErrorMessage", GetNullableString(reader, i++));
SetParameter(command, "@DeletedLocalFilesAfterUpload", GetBoolean(reader, i++));
SetParameter(command, "@DeletedLocalFilesAfterUpload", GetNullableBoolean(reader, i++) ?? false);
SetParameter(command, "@CreatedAt", GetDateTimeOffset(reader, i++));
},
cancellationToken);
@@ -852,9 +852,9 @@ public sealed partial class FfmpegService
// RecordTaskId unique constraint races between scoped DbContext instances.
await dbContext.Database.ExecuteSqlInterpolatedAsync($"""
INSERT INTO "RecordResults"
("Id", "RecordTaskId", "FilePath", "FileSizeBytes", "DurationSeconds", "DanmakuFilePath", "DanmakuMessageCount", "FinalStatus", "ErrorMessage", "CreatedAt")
("Id", "RecordTaskId", "FilePath", "FileSizeBytes", "DurationSeconds", "DanmakuFilePath", "DanmakuMessageCount", "FinalStatus", "ErrorMessage", "UploadStatus", "DeletedLocalFilesAfterUpload", "CreatedAt")
VALUES
({resultId}, {recordTask.Id}, {effectiveOutputPath}, {fileSize}, {durationSeconds}, {danmakuFilePath}, {normalizedDanmakuCount}, {finalStatus}, {recordTask.ErrorMessage}, {endedAt})
({resultId}, {recordTask.Id}, {effectiveOutputPath}, {fileSize}, {durationSeconds}, {danmakuFilePath}, {normalizedDanmakuCount}, {finalStatus}, {recordTask.ErrorMessage}, {(int)RecordArtifactUploadStatus.NotUploaded}, {false}, {endedAt})
ON CONFLICT("RecordTaskId") DO UPDATE SET
"FilePath" = excluded."FilePath",
"FileSizeBytes" = excluded."FileSizeBytes",
@@ -862,7 +862,9 @@ public sealed partial class FfmpegService
"DanmakuFilePath" = excluded."DanmakuFilePath",
"DanmakuMessageCount" = excluded."DanmakuMessageCount",
"FinalStatus" = excluded."FinalStatus",
"ErrorMessage" = excluded."ErrorMessage";
"ErrorMessage" = excluded."ErrorMessage",
"UploadStatus" = COALESCE("RecordResults"."UploadStatus", excluded."UploadStatus"),
"DeletedLocalFilesAfterUpload" = COALESCE("RecordResults"."DeletedLocalFilesAfterUpload", excluded."DeletedLocalFilesAfterUpload");
""", cancellationToken);
}