aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcrobibero <cody@robibe.ro>2025-10-27 15:43:29 -0400
committerBond_009 <bond.009@outlook.com>2025-10-27 15:43:29 -0400
commita489942454218fc968baf7858ee00ee9141ebfb5 (patch)
tree540711d6132e49cf894e6626a14970f89e534158
parent423c2654c087e9c23fafe6766ccc7168b6b2dd3a (diff)
Backport pull request #15212 from jellyfin/release-10.11.z
Skip invalid database migration Original-merge: 2966d27c97542fae111b54526326b8a93fcf7ca6 Merged-by: crobibero <cody@robibe.ro> Backported-by: Bond_009 <bond.009@outlook.com>
-rw-r--r--Jellyfin.Server/Migrations/Routines/MigrateActivityLogDb.cs18
-rw-r--r--Jellyfin.Server/Migrations/Routines/MigrateUserDb.cs19
2 files changed, 35 insertions, 2 deletions
diff --git a/Jellyfin.Server/Migrations/Routines/MigrateActivityLogDb.cs b/Jellyfin.Server/Migrations/Routines/MigrateActivityLogDb.cs
index a954d307e..b36db347c 100644
--- a/Jellyfin.Server/Migrations/Routines/MigrateActivityLogDb.cs
+++ b/Jellyfin.Server/Migrations/Routines/MigrateActivityLogDb.cs
@@ -55,9 +55,25 @@ namespace Jellyfin.Server.Migrations.Routines
};
var dataPath = _paths.DataPath;
- using (var connection = new SqliteConnection($"Filename={Path.Combine(dataPath, DbFilename)}"))
+ var activityLogPath = Path.Combine(dataPath, DbFilename);
+ if (!File.Exists(activityLogPath))
+ {
+ _logger.LogWarning("{ActivityLogDb} doesn't exist, nothing to migrate", activityLogPath);
+ return;
+ }
+
+ using (var connection = new SqliteConnection($"Filename={activityLogPath}"))
{
connection.Open();
+ var tableQuery = connection.Query("SELECT count(*) FROM sqlite_master WHERE type='table' AND name='ActivityLog';");
+ foreach (var row in tableQuery)
+ {
+ if (row.GetInt32(0) == 0)
+ {
+ _logger.LogWarning("Table 'ActivityLog' doesn't exist in {ActivityLogPath}, nothing to migrate", activityLogPath);
+ break;
+ }
+ }
using var userDbConnection = new SqliteConnection($"Filename={Path.Combine(dataPath, "users.db")}");
userDbConnection.Open();
diff --git a/Jellyfin.Server/Migrations/Routines/MigrateUserDb.cs b/Jellyfin.Server/Migrations/Routines/MigrateUserDb.cs
index e5584fb94..c3f07c089 100644
--- a/Jellyfin.Server/Migrations/Routines/MigrateUserDb.cs
+++ b/Jellyfin.Server/Migrations/Routines/MigrateUserDb.cs
@@ -57,11 +57,28 @@ public class MigrateUserDb : IMigrationRoutine
public void Perform()
{
var dataPath = _paths.DataPath;
+ var userDbPath = Path.Combine(dataPath, DbFilename);
+ if (!File.Exists(userDbPath))
+ {
+ _logger.LogWarning("{UserDbPath} doesn't exist, nothing to migrate", userDbPath);
+ return;
+ }
+
_logger.LogInformation("Migrating the user database may take a while, do not stop Jellyfin.");
- using (var connection = new SqliteConnection($"Filename={Path.Combine(dataPath, DbFilename)}"))
+ using (var connection = new SqliteConnection($"Filename={userDbPath}"))
{
connection.Open();
+ var tableQuery = connection.Query("SELECT count(*) FROM sqlite_master WHERE type='table' AND name='LocalUsersv2';");
+ foreach (var row in tableQuery)
+ {
+ if (row.GetInt32(0) == 0)
+ {
+ _logger.LogWarning("Table 'LocalUsersv2' doesn't exist in {UserDbPath}, nothing to migrate", userDbPath);
+ break;
+ }
+ }
+
using var dbContext = _provider.CreateDbContext();
var queryResult = connection.Query("SELECT * FROM LocalUsersv2");