mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-19 17:32:38 +01:00
Fixed: Correctly handle Migration when PG Host has ".db"
(cherry picked from commit 97ee24507f4306e3b62c3d00cd3ade6a09d1b957) Closes #9478
This commit is contained in:
parent
229d91fe40
commit
fa62f3f66a
@ -68,7 +68,7 @@ public IDatabase Create(MigrationContext migrationContext)
|
|||||||
case MigrationType.Main:
|
case MigrationType.Main:
|
||||||
{
|
{
|
||||||
connectionInfo = _connectionStringFactory.MainDbConnection;
|
connectionInfo = _connectionStringFactory.MainDbConnection;
|
||||||
CreateMain(connectionInfo.ConnectionString, migrationContext);
|
CreateMain(connectionInfo.ConnectionString, migrationContext, connectionInfo.DatabaseType);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -76,7 +76,7 @@ public IDatabase Create(MigrationContext migrationContext)
|
|||||||
case MigrationType.Log:
|
case MigrationType.Log:
|
||||||
{
|
{
|
||||||
connectionInfo = _connectionStringFactory.LogDbConnection;
|
connectionInfo = _connectionStringFactory.LogDbConnection;
|
||||||
CreateLog(connectionInfo.ConnectionString, migrationContext);
|
CreateLog(connectionInfo.ConnectionString, migrationContext, connectionInfo.DatabaseType);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -108,12 +108,12 @@ public IDatabase Create(MigrationContext migrationContext)
|
|||||||
return db;
|
return db;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CreateMain(string connectionString, MigrationContext migrationContext)
|
private void CreateMain(string connectionString, MigrationContext migrationContext, DatabaseType databaseType)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_restoreDatabaseService.Restore();
|
_restoreDatabaseService.Restore();
|
||||||
_migrationController.Migrate(connectionString, migrationContext);
|
_migrationController.Migrate(connectionString, migrationContext, databaseType);
|
||||||
}
|
}
|
||||||
catch (SQLiteException e)
|
catch (SQLiteException e)
|
||||||
{
|
{
|
||||||
@ -140,7 +140,7 @@ private void CreateMain(string connectionString, MigrationContext migrationConte
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_migrationController.Migrate(connectionString, migrationContext);
|
_migrationController.Migrate(connectionString, migrationContext, databaseType);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -165,11 +165,11 @@ private void CreateMain(string connectionString, MigrationContext migrationConte
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CreateLog(string connectionString, MigrationContext migrationContext)
|
private void CreateLog(string connectionString, MigrationContext migrationContext, DatabaseType databaseType)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_migrationController.Migrate(connectionString, migrationContext);
|
_migrationController.Migrate(connectionString, migrationContext, databaseType);
|
||||||
}
|
}
|
||||||
catch (SQLiteException e)
|
catch (SQLiteException e)
|
||||||
{
|
{
|
||||||
@ -189,7 +189,7 @@ private void CreateLog(string connectionString, MigrationContext migrationContex
|
|||||||
Logger.Error("Unable to recreate logging database automatically. It will need to be removed manually.");
|
Logger.Error("Unable to recreate logging database automatically. It will need to be removed manually.");
|
||||||
}
|
}
|
||||||
|
|
||||||
_migrationController.Migrate(connectionString, migrationContext);
|
_migrationController.Migrate(connectionString, migrationContext, databaseType);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -14,7 +14,7 @@ namespace NzbDrone.Core.Datastore.Migration.Framework
|
|||||||
{
|
{
|
||||||
public interface IMigrationController
|
public interface IMigrationController
|
||||||
{
|
{
|
||||||
void Migrate(string connectionString, MigrationContext migrationContext);
|
void Migrate(string connectionString, MigrationContext migrationContext, DatabaseType databaseType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MigrationController : IMigrationController
|
public class MigrationController : IMigrationController
|
||||||
@ -29,7 +29,7 @@ public MigrationController(Logger logger,
|
|||||||
_migrationLoggerProvider = migrationLoggerProvider;
|
_migrationLoggerProvider = migrationLoggerProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Migrate(string connectionString, MigrationContext migrationContext)
|
public void Migrate(string connectionString, MigrationContext migrationContext, DatabaseType databaseType)
|
||||||
{
|
{
|
||||||
var sw = Stopwatch.StartNew();
|
var sw = Stopwatch.StartNew();
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ public void Migrate(string connectionString, MigrationContext migrationContext)
|
|||||||
|
|
||||||
ServiceProvider serviceProvider;
|
ServiceProvider serviceProvider;
|
||||||
|
|
||||||
var db = connectionString.Contains(".db") ? "sqlite" : "postgres";
|
var db = databaseType == DatabaseType.SQLite ? "sqlite" : "postgres";
|
||||||
|
|
||||||
serviceProvider = new ServiceCollection()
|
serviceProvider = new ServiceCollection()
|
||||||
.AddLogging(b => b.AddNLog())
|
.AddLogging(b => b.AddNLog())
|
||||||
|
Loading…
Reference in New Issue
Block a user