Bugfix/reader progress (#435)

Fixed: Fixed an issue where marking a series as Unread when the DB gets skewed with duplicate progress rows for that item, would break. Now we cleanup any extra rows we see during the operation.
This commit is contained in:
Joseph Milazzo 2021-07-25 17:31:42 -05:00 committed by GitHub
parent 2209a65d52
commit 66f40656dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 134 additions and 20 deletions

View file

@ -9,6 +9,7 @@ using API.Entities.Enums;
using API.Services;
using Kavita.Common;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
namespace API.Data
{
@ -69,5 +70,21 @@ namespace API.Data
await context.SaveChangesAsync();
}
public static async Task SeedSeriesMetadata(DataContext context)
{
await context.Database.EnsureCreatedAsync();
context.Database.EnsureCreated();
var series = await context.Series
.Include(s => s.Metadata).ToListAsync();
foreach (var s in series)
{
s.Metadata ??= new SeriesMetadata();
}
await context.SaveChangesAsync();
}
}
}