forked from Kareadita/Kavita
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Samuel Martins <[email protected]> Co-authored-by: Robbie Davis <[email protected]>
- Loading branch information
1 parent
97ffdd0
commit b50fa0f
Showing
45 changed files
with
563 additions
and
282 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
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> | ||
/// v0.8.2 switches Default Kavita installs to WAL | ||
/// </summary> | ||
public static class ManualMigrateSwitchToWal | ||
{ | ||
public static async Task Migrate(DataContext context, ILogger<Program> logger) | ||
{ | ||
if (await context.ManualMigrationHistory.AnyAsync(m => m.Name == "ManualMigrateSwitchToWal")) | ||
{ | ||
return; | ||
} | ||
|
||
logger.LogCritical("Running ManualMigrateSwitchToWal migration - Please be patient, this may take some time. This is not an error"); | ||
try | ||
{ | ||
var connection = context.Database.GetDbConnection(); | ||
await connection.OpenAsync(); | ||
await using var command = connection.CreateCommand(); | ||
command.CommandText = "PRAGMA journal_mode=WAL;"; | ||
await command.ExecuteNonQueryAsync(); | ||
} | ||
catch (Exception ex) | ||
{ | ||
logger.LogError(ex, "Error setting WAL"); | ||
/* Swallow */ | ||
} | ||
|
||
await context.ManualMigrationHistory.AddAsync(new ManualMigrationHistory() | ||
{ | ||
Name = "ManualMigrateSwitchToWal", | ||
ProductVersion = BuildInfo.Version.ToString(), | ||
RanAt = DateTime.UtcNow | ||
}); | ||
await context.SaveChangesAsync(); | ||
|
||
logger.LogCritical("Running ManualMigrateSwitchToWal migration - Completed. This is not an error"); | ||
} | ||
|
||
} |
49 changes: 49 additions & 0 deletions
49
API/Data/ManualMigrations/ManualMigrateThemeDescription.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,49 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using API.Entities; | ||
using Kavita.Common.EnvironmentInfo; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace API.Data.ManualMigrations; | ||
|
||
/// <summary> | ||
/// v0.8.2 introduced Theme repo viewer, this adds Description to existing SiteTheme defaults | ||
/// </summary> | ||
public static class ManualMigrateThemeDescription | ||
{ | ||
public static async Task Migrate(DataContext context, ILogger<Program> logger) | ||
{ | ||
if (await context.ManualMigrationHistory.AnyAsync(m => m.Name == "ManualMigrateThemeDescription")) | ||
{ | ||
return; | ||
} | ||
|
||
logger.LogCritical("Running ManualMigrateThemeDescription migration - Please be patient, this may take some time. This is not an error"); | ||
|
||
var theme = await context.SiteTheme.FirstOrDefaultAsync(t => t.Name == "Dark"); | ||
if (theme != null) | ||
{ | ||
theme.Description = Seed.DefaultThemes.First().Description; | ||
} | ||
|
||
if (context.ChangeTracker.HasChanges()) | ||
{ | ||
await context.SaveChangesAsync(); | ||
} | ||
|
||
|
||
|
||
|
||
await context.ManualMigrationHistory.AddAsync(new ManualMigrationHistory() | ||
{ | ||
Name = "ManualMigrateThemeDescription", | ||
ProductVersion = BuildInfo.Version.ToString(), | ||
RanAt = DateTime.UtcNow | ||
}); | ||
await context.SaveChangesAsync(); | ||
|
||
logger.LogCritical("Running ManualMigrateThemeDescription 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
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
Oops, something went wrong.