feat: migrate runtime to postgresql
This commit is contained in:
@@ -848,21 +848,21 @@ public sealed partial class FfmpegService
|
||||
var finalStatus = (int)recordTask.Status;
|
||||
|
||||
// Multiple background paths can reconcile the same segment after ffmpeg exits.
|
||||
// Use SQLite's atomic upsert instead of EF Add-or-Update to avoid RecordTaskId
|
||||
// unique constraint races between scoped DbContext instances.
|
||||
// Use the database's atomic upsert instead of EF Add-or-Update to avoid
|
||||
// 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)
|
||||
INSERT INTO "RecordResults"
|
||||
("Id", "RecordTaskId", "FilePath", "FileSizeBytes", "DurationSeconds", "DanmakuFilePath", "DanmakuMessageCount", "FinalStatus", "ErrorMessage", "CreatedAt")
|
||||
VALUES
|
||||
({resultId}, {recordTask.Id}, {effectiveOutputPath}, {fileSize}, {durationSeconds}, {danmakuFilePath}, {normalizedDanmakuCount}, {finalStatus}, {recordTask.ErrorMessage}, {endedAt})
|
||||
ON CONFLICT(RecordTaskId) DO UPDATE SET
|
||||
FilePath = excluded.FilePath,
|
||||
FileSizeBytes = excluded.FileSizeBytes,
|
||||
DurationSeconds = excluded.DurationSeconds,
|
||||
DanmakuFilePath = excluded.DanmakuFilePath,
|
||||
DanmakuMessageCount = excluded.DanmakuMessageCount,
|
||||
FinalStatus = excluded.FinalStatus,
|
||||
ErrorMessage = excluded.ErrorMessage;
|
||||
ON CONFLICT("RecordTaskId") DO UPDATE SET
|
||||
"FilePath" = excluded."FilePath",
|
||||
"FileSizeBytes" = excluded."FileSizeBytes",
|
||||
"DurationSeconds" = excluded."DurationSeconds",
|
||||
"DanmakuFilePath" = excluded."DanmakuFilePath",
|
||||
"DanmakuMessageCount" = excluded."DanmakuMessageCount",
|
||||
"FinalStatus" = excluded."FinalStatus",
|
||||
"ErrorMessage" = excluded."ErrorMessage";
|
||||
""", cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user