mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-21 05:53:33 -07:00
Marr is almost working.
This commit is contained in:
parent
971053f8a2
commit
ea4f0dbe5f
18 changed files with 300 additions and 126 deletions
|
@ -0,0 +1,39 @@
|
|||
using System.Reflection;
|
||||
using FluentMigrator.Runner;
|
||||
using FluentMigrator.Runner.Initialization;
|
||||
using NzbDrone.Core.Datastore.Migration.Sqlite;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migration.Framework
|
||||
{
|
||||
public interface IMigrationController
|
||||
{
|
||||
void MigrateToLatest(string connectionString, MigrationType migrationType);
|
||||
}
|
||||
|
||||
public class MigrationController : IMigrationController
|
||||
{
|
||||
private readonly IAnnouncer _announcer;
|
||||
|
||||
public MigrationController(IAnnouncer announcer)
|
||||
{
|
||||
_announcer = announcer;
|
||||
}
|
||||
|
||||
public void MigrateToLatest(string connectionString, MigrationType migrationType)
|
||||
{
|
||||
var assembly = Assembly.GetExecutingAssembly();
|
||||
|
||||
var migrationContext = new RunnerContext(_announcer)
|
||||
{
|
||||
Namespace = "NzbDrone.Core.Datastore.Migration",
|
||||
ApplicationContext = migrationType
|
||||
};
|
||||
|
||||
var options = new MigrationOptions { PreviewOnly = false, Timeout = 60 };
|
||||
var factory = new MonoSqliteProcessorFactory();
|
||||
var processor = factory.Create(connectionString, _announcer, options);
|
||||
var runner = new MigrationRunner(assembly, migrationContext, processor);
|
||||
runner.MigrateUp(true);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
using FluentMigrator;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migration.Framework
|
||||
{
|
||||
public class MigrationOptions : IMigrationProcessorOptions
|
||||
{
|
||||
public bool PreviewOnly { get; set; }
|
||||
public int Timeout { get; set; }
|
||||
}
|
||||
}
|
15
NzbDrone.Core/Datastore/Migration/Framework/NlogAnnouncer.cs
Normal file
15
NzbDrone.Core/Datastore/Migration/Framework/NlogAnnouncer.cs
Normal file
|
@ -0,0 +1,15 @@
|
|||
using FluentMigrator.Runner.Announcers;
|
||||
using NLog;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migration.Framework
|
||||
{
|
||||
public class NlogAnnouncer : Announcer
|
||||
{
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public override void Write(string message, bool escaped)
|
||||
{
|
||||
logger.Info(message);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
using System;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migration.Framework
|
||||
{
|
||||
public abstract class NzbDroneMigrationBase : FluentMigrator.Migration
|
||||
{
|
||||
protected virtual void MainDbUpgrade()
|
||||
{
|
||||
}
|
||||
|
||||
protected virtual void LogDbUpgrade()
|
||||
{
|
||||
}
|
||||
|
||||
public override void Up()
|
||||
{
|
||||
if ((MigrationType)ApplicationContext == MigrationType.Main)
|
||||
{
|
||||
MainDbUpgrade();
|
||||
}
|
||||
else if ((MigrationType)ApplicationContext == MigrationType.Log)
|
||||
{
|
||||
LogDbUpgrade();
|
||||
}
|
||||
else
|
||||
{
|
||||
LogDbUpgrade();
|
||||
MainDbUpgrade();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue