aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Startup.Common/Migrations/DbMigration.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Server.Startup.Common/Migrations/DbMigration.cs')
-rw-r--r--MediaBrowser.Server.Startup.Common/Migrations/DbMigration.cs32
1 files changed, 32 insertions, 0 deletions
diff --git a/MediaBrowser.Server.Startup.Common/Migrations/DbMigration.cs b/MediaBrowser.Server.Startup.Common/Migrations/DbMigration.cs
new file mode 100644
index 000000000..cdb69025a
--- /dev/null
+++ b/MediaBrowser.Server.Startup.Common/Migrations/DbMigration.cs
@@ -0,0 +1,32 @@
+using System.Threading.Tasks;
+using MediaBrowser.Common.ScheduledTasks;
+using MediaBrowser.Controller.Configuration;
+using MediaBrowser.Server.Implementations.Persistence;
+
+namespace MediaBrowser.Server.Startup.Common.Migrations
+{
+ public class DbMigration : IVersionMigration
+ {
+ private readonly IServerConfigurationManager _config;
+ private readonly ITaskManager _taskManager;
+
+ public DbMigration(IServerConfigurationManager config, ITaskManager taskManager)
+ {
+ _config = config;
+ _taskManager = taskManager;
+ }
+
+ public void Run()
+ {
+ if (_config.Configuration.MigrationVersion < CleanDatabaseScheduledTask.MigrationVersion)
+ {
+ Task.Run(async () =>
+ {
+ await Task.Delay(2000).ConfigureAwait(false);
+
+ _taskManager.QueueScheduledTask<CleanDatabaseScheduledTask>();
+ });
+ }
+ }
+ }
+}