|
|
@ -1,4 +1,6 @@
|
|
|
|
using System.Reflection;
|
|
|
|
using System.Collections.Concurrent;
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
using System.Reflection;
|
|
|
|
using FluentMigrator.Runner;
|
|
|
|
using FluentMigrator.Runner;
|
|
|
|
using FluentMigrator.Runner.Initialization;
|
|
|
|
using FluentMigrator.Runner.Initialization;
|
|
|
|
using FluentMigrator.Runner.Processors.Sqlite;
|
|
|
|
using FluentMigrator.Runner.Processors.Sqlite;
|
|
|
@ -14,6 +16,8 @@ namespace NzbDrone.Core.Datastore.Migration.Framework
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private readonly IAnnouncer _announcer;
|
|
|
|
private readonly IAnnouncer _announcer;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static readonly HashSet<string> MigrationCache = new HashSet<string>();
|
|
|
|
|
|
|
|
|
|
|
|
public MigrationController(IAnnouncer announcer)
|
|
|
|
public MigrationController(IAnnouncer announcer)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_announcer = announcer;
|
|
|
|
_announcer = announcer;
|
|
|
@ -21,6 +25,10 @@ namespace NzbDrone.Core.Datastore.Migration.Framework
|
|
|
|
|
|
|
|
|
|
|
|
public void MigrateToLatest(string connectionString, MigrationType migrationType)
|
|
|
|
public void MigrateToLatest(string connectionString, MigrationType migrationType)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
lock (MigrationCache)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (MigrationCache.Contains(connectionString.ToLower())) return;
|
|
|
|
|
|
|
|
|
|
|
|
var assembly = Assembly.GetExecutingAssembly();
|
|
|
|
var assembly = Assembly.GetExecutingAssembly();
|
|
|
|
|
|
|
|
|
|
|
|
var migrationContext = new RunnerContext(_announcer)
|
|
|
|
var migrationContext = new RunnerContext(_announcer)
|
|
|
@ -34,6 +42,9 @@ namespace NzbDrone.Core.Datastore.Migration.Framework
|
|
|
|
var processor = factory.Create(connectionString, _announcer, options);
|
|
|
|
var processor = factory.Create(connectionString, _announcer, options);
|
|
|
|
var runner = new MigrationRunner(assembly, migrationContext, processor);
|
|
|
|
var runner = new MigrationRunner(assembly, migrationContext, processor);
|
|
|
|
runner.MigrateUp(true);
|
|
|
|
runner.MigrateUp(true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MigrationCache.Add(connectionString.ToLower());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|