aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2025-04-02 20:42:35 -0500
committerJP Dillingham <jp@dillingham.me>2025-04-02 20:42:35 -0500
commit47ea1847f89df9ca2ab2e7a51e29bab27f60f89b (patch)
tree5848bce732b4af93f8e7afb451946d81bc86c47b /src/slskd
parente08b71168e64928f0664eab2b7c070b9d20b6783 (diff)
downloadslskd-47ea1847f89df9ca2ab2e7a51e29bab27f60f89b.tar.gz
migrate if migrator exists
Diffstat (limited to 'src/slskd')
-rw-r--r--src/slskd/Core/Migrator.cs8
-rw-r--r--src/slskd/Program.cs7
2 files changed, 15 insertions, 0 deletions
diff --git a/src/slskd/Core/Migrator.cs b/src/slskd/Core/Migrator.cs
index a83f4764..23580336 100644
--- a/src/slskd/Core/Migrator.cs
+++ b/src/slskd/Core/Migrator.cs
@@ -20,6 +20,7 @@ namespace slskd;
using System;
using System.Collections.Generic;
using System.IO;
+using System.Linq;
using Serilog;
using slskd.Migrations;
@@ -60,6 +61,13 @@ public class Migrator
}
}
+ var migrationsNotYetApplied = Migrations.Keys.Except(history.Keys);
+
+ if (!migrationsNotYetApplied.Any())
+ {
+ Log.Debug("No migrations need to be applied");
+ }
+
foreach (var migration in Migrations)
{
if (history.TryGetValue(migration.Key, out var timestamp))
diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs
index 50ae7a07..8fbc0522 100644
--- a/src/slskd/Program.cs
+++ b/src/slskd/Program.cs
@@ -494,6 +494,13 @@ namespace slskd
var app = builder.Build();
+ var migrator = app.Services.GetService<Migrator>();
+
+ if (migrator is not null)
+ {
+ migrator.Migrate();
+ }
+
// hack: services that exist only to subscribe to the event bus are not referenced by anything else
// and are thus never instantiated. force a reference here so they are created.
_ = app.Services.GetService<ScriptService>();