Float-based Volumes (#2659)
This commit is contained in:
parent
6fdc9228df
commit
f6af6d66be
44 changed files with 3106 additions and 184 deletions
38
API/Data/ManualMigrations/MigrateVolumeNumber.cs
Normal file
38
API/Data/ManualMigrations/MigrateVolumeNumber.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using API.Entities.Enums;
|
||||
using API.Services.Tasks.Scanner.Parser;
|
||||
using Kavita.Common.EnvironmentInfo;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace API.Data.ManualMigrations;
|
||||
|
||||
/// <summary>
|
||||
/// Introduced in v0.7.14, this migrates the existing Volume Name -> Volume Min/Max Number
|
||||
/// </summary>
|
||||
public static class MigrateVolumeNumber
|
||||
{
|
||||
public static async Task Migrate(IUnitOfWork unitOfWork, DataContext dataContext, ILogger<Program> logger)
|
||||
{
|
||||
logger.LogCritical(
|
||||
"Running MigrateVolumeNumber migration - Please be patient, this may take some time. This is not an error");
|
||||
if (await dataContext.Volume.AnyAsync(v => v.MaxNumber > 0))
|
||||
{
|
||||
logger.LogCritical(
|
||||
"Running MigrateVolumeNumber migration - Completed. This is not an error");
|
||||
return;
|
||||
}
|
||||
|
||||
// Get all volumes
|
||||
foreach (var volume in dataContext.Volume)
|
||||
{
|
||||
volume.MinNumber = Parser.MinNumberFromRange(volume.Name);
|
||||
volume.MaxNumber = Parser.MaxNumberFromRange(volume.Name);
|
||||
}
|
||||
|
||||
await dataContext.SaveChangesAsync();
|
||||
logger.LogCritical(
|
||||
"Running MigrateVolumeNumber migration - Completed. This is not an error");
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue