mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-10-02 00:34:37 +02:00
Autofac registrations are not singleton anymore.
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using System.Reflection;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using FluentMigrator.Runner;
|
||||
using FluentMigrator.Runner.Initialization;
|
||||
using FluentMigrator.Runner.Processors.Sqlite;
|
||||
@@ -14,6 +16,8 @@ namespace NzbDrone.Core.Datastore.Migration.Framework
|
||||
{
|
||||
private readonly IAnnouncer _announcer;
|
||||
|
||||
private static readonly HashSet<string> MigrationCache = new HashSet<string>();
|
||||
|
||||
public MigrationController(IAnnouncer announcer)
|
||||
{
|
||||
_announcer = announcer;
|
||||
@@ -21,19 +25,26 @@ namespace NzbDrone.Core.Datastore.Migration.Framework
|
||||
|
||||
public void MigrateToLatest(string connectionString, MigrationType migrationType)
|
||||
{
|
||||
var assembly = Assembly.GetExecutingAssembly();
|
||||
|
||||
var migrationContext = new RunnerContext(_announcer)
|
||||
lock (MigrationCache)
|
||||
{
|
||||
Namespace = "NzbDrone.Core.Datastore.Migration",
|
||||
ApplicationContext = migrationType
|
||||
};
|
||||
if (MigrationCache.Contains(connectionString.ToLower())) return;
|
||||
|
||||
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);
|
||||
runner.MigrateUp(true);
|
||||
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 SqliteProcessorFactory();
|
||||
var processor = factory.Create(connectionString, _announcer, options);
|
||||
var runner = new MigrationRunner(assembly, migrationContext, processor);
|
||||
runner.MigrateUp(true);
|
||||
|
||||
MigrationCache.Add(connectionString.ToLower());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user