removed migrationcache

pull/3113/head
kayone 11 years ago committed by Mark McDowall
parent abd994ef71
commit 5117eaaf5c

@ -1,5 +1,4 @@
using System.Collections.Generic; using System.Reflection;
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;
@ -17,8 +16,6 @@ namespace NzbDrone.Core.Datastore.Migration.Framework
private readonly ISQLiteAlter _sqLiteAlter; private readonly ISQLiteAlter _sqLiteAlter;
private readonly ISqLiteMigrationHelper _migrationHelper; private readonly ISqLiteMigrationHelper _migrationHelper;
private static readonly HashSet<string> MigrationCache = new HashSet<string>();
public MigrationController(IAnnouncer announcer, ISQLiteAlter sqLiteAlter, ISqLiteMigrationHelper migrationHelper) public MigrationController(IAnnouncer announcer, ISQLiteAlter sqLiteAlter, ISqLiteMigrationHelper migrationHelper)
{ {
_announcer = announcer; _announcer = announcer;
@ -28,33 +25,26 @@ namespace NzbDrone.Core.Datastore.Migration.Framework
public void MigrateToLatest(string connectionString, MigrationType migrationType) public void MigrateToLatest(string connectionString, MigrationType migrationType)
{ {
lock (MigrationCache) _announcer.Heading("Migrating " + connectionString);
{
if (MigrationCache.Contains(connectionString.ToLower())) return; var assembly = Assembly.GetExecutingAssembly();
_announcer.Heading("Migrating " + connectionString); var migrationContext = new RunnerContext(_announcer)
{
var assembly = Assembly.GetExecutingAssembly(); Namespace = "NzbDrone.Core.Datastore.Migration",
ApplicationContext = new MigrationContext
var migrationContext = new RunnerContext(_announcer) {
{ MigrationType = migrationType,
Namespace = "NzbDrone.Core.Datastore.Migration", SQLiteAlter = _sqLiteAlter,
ApplicationContext = new MigrationContext MigrationHelper = _migrationHelper,
{ }
MigrationType = migrationType, };
SQLiteAlter = _sqLiteAlter,
MigrationHelper = _migrationHelper, var options = new MigrationOptions { PreviewOnly = false, Timeout = 60 };
} var factory = new SqliteProcessorFactory();
}; var processor = factory.Create(connectionString, _announcer, options);
var runner = new MigrationRunner(assembly, migrationContext, processor);
var options = new MigrationOptions { PreviewOnly = false, Timeout = 60 }; runner.MigrateUp(true);
var factory = new SqliteProcessorFactory();
var processor = factory.Create(connectionString, _announcer, options);
var runner = new MigrationRunner(assembly, migrationContext, processor);
runner.MigrateUp(true);
MigrationCache.Add(connectionString.ToLower());
}
} }
} }
} }

Loading…
Cancel
Save