Refactor SQLite Database Provider

- Removed unused classes and files related to SQLite database provider, including SqliteDesignTimeJellyfinDbFactory, ModelBuilderExtensions, PragmaConnectionInterceptor, AssemblyInfo, SqliteDatabaseProvider, DateTimeKindValueConverter.
- Updated tests to remove dependencies on removed classes and adjusted mocking for configuration sections.
- Added Microsoft.EntityFrameworkCore.Sqlite package reference to test project.
- Improved string handling in tests for better consistency and clarity.
- Refactored logging methods in JellyfinApplicationFactory for better readability and maintainability.
This commit is contained in:
2026-05-03 09:39:00 -04:00
parent e1f7a4bee9
commit 3e5d29225a
249 changed files with 72112 additions and 50310 deletions
@@ -40,37 +40,43 @@ internal class MigrateRatingLevels : IDatabaseMigrationRoutine
{
_logger.LogInformation("Recalculating parental rating levels based on rating string.");
using var context = _provider.CreateDbContext();
using var transaction = context.Database.BeginTransaction();
// Materialize the ratings list first to avoid "command in progress" error
var ratings = context.BaseItems.AsNoTracking().Select(e => e.OfficialRating).Distinct().ToList();
foreach (var rating in ratings)
// NpgsqlRetryingExecutionStrategy requires all operations inside a user-initiated
// transaction to be wrapped with CreateExecutionStrategy().Execute(...).
context.Database.CreateExecutionStrategy().Execute(() =>
{
if (string.IsNullOrEmpty(rating))
{
int? value = null;
context.BaseItems
.Where(e => e.OfficialRating == null || e.OfficialRating == string.Empty)
.ExecuteUpdate(f => f.SetProperty(e => e.InheritedParentalRatingValue, value));
context.BaseItems
.Where(e => e.OfficialRating == null || e.OfficialRating == string.Empty)
.ExecuteUpdate(f => f.SetProperty(e => e.InheritedParentalRatingSubValue, value));
}
else
{
var ratingValue = _localizationManager.GetRatingScore(rating);
var score = ratingValue?.Score;
var subScore = ratingValue?.SubScore;
context.BaseItems
.Where(e => e.OfficialRating == rating)
.ExecuteUpdate(f => f.SetProperty(e => e.InheritedParentalRatingValue, score));
context.BaseItems
.Where(e => e.OfficialRating == rating)
.ExecuteUpdate(f => f.SetProperty(e => e.InheritedParentalRatingSubValue, subScore));
}
}
using var transaction = context.Database.BeginTransaction();
transaction.Commit();
// Materialize the ratings list first to avoid "command in progress" error
var ratings = context.BaseItems.AsNoTracking().Select(e => e.OfficialRating).Distinct().ToList();
foreach (var rating in ratings)
{
if (string.IsNullOrEmpty(rating))
{
int? value = null;
context.BaseItems
.Where(e => e.OfficialRating == null || e.OfficialRating == string.Empty)
.ExecuteUpdate(f => f.SetProperty(e => e.InheritedParentalRatingValue, value));
context.BaseItems
.Where(e => e.OfficialRating == null || e.OfficialRating == string.Empty)
.ExecuteUpdate(f => f.SetProperty(e => e.InheritedParentalRatingSubValue, value));
}
else
{
var ratingValue = _localizationManager.GetRatingScore(rating);
var score = ratingValue?.Score;
var subScore = ratingValue?.SubScore;
context.BaseItems
.Where(e => e.OfficialRating == rating)
.ExecuteUpdate(f => f.SetProperty(e => e.InheritedParentalRatingValue, score));
context.BaseItems
.Where(e => e.OfficialRating == rating)
.ExecuteUpdate(f => f.SetProperty(e => e.InheritedParentalRatingSubValue, subScore));
}
}
transaction.Commit();
});
}
}