-
-
Notifications
You must be signed in to change notification settings - Fork 364
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
149c30b
commit 355ea24
Showing
6 changed files
with
72 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
API/Data/ManualMigrations/MigrateClearNightlyExternalSeriesRecords.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using API.Entities; | ||
using Kavita.Common.EnvironmentInfo; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace API.Data.ManualMigrations; | ||
|
||
/// <summary> | ||
/// For the v0.7.14 release, one of the nightlies had bad data that would cause issues. This drops those records | ||
/// </summary> | ||
public static class MigrateClearNightlyExternalSeriesRecords | ||
{ | ||
public static async Task Migrate(DataContext dataContext, ILogger<Program> logger) | ||
{ | ||
if (await dataContext.ManualMigrationHistory.AnyAsync(m => m.Name == "MigrateClearNightlyExternalSeriesRecords")) | ||
{ | ||
return; | ||
} | ||
|
||
logger.LogCritical( | ||
"Running MigrateClearNightlyExternalSeriesRecords migration - Please be patient, this may take some time. This is not an error"); | ||
|
||
dataContext.ExternalSeriesMetadata.RemoveRange(dataContext.ExternalSeriesMetadata); | ||
dataContext.ExternalRating.RemoveRange(dataContext.ExternalRating); | ||
dataContext.ExternalRecommendation.RemoveRange(dataContext.ExternalRecommendation); | ||
dataContext.ExternalReview.RemoveRange(dataContext.ExternalReview); | ||
|
||
dataContext.ManualMigrationHistory.Add(new ManualMigrationHistory() | ||
{ | ||
Name = "MigrateClearNightlyExternalSeriesRecords", | ||
ProductVersion = BuildInfo.Version.ToString(), | ||
RanAt = DateTime.UtcNow | ||
}); | ||
|
||
await dataContext.SaveChangesAsync(); | ||
|
||
logger.LogCritical( | ||
"Running MigrateClearNightlyExternalSeriesRecords migration - Completed. This is not an error"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters