aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2025-04-03 20:17:03 -0500
committerJP Dillingham <jp@dillingham.me>2025-04-03 20:17:03 -0500
commit571617de9bff8d4a045c1857da97cc2ba787d5ef (patch)
treec5dd44148555adf5b7172f52d944c9ed16a74a35 /src
parent3004a4297466d97b258033c874580a10536716be (diff)
downloadslskd-571617de9bff8d4a045c1857da97cc2ba787d5ef.tar.gz
run migrations when non-volatile
Diffstat (limited to 'src')
-rw-r--r--src/slskd/Program.cs11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs
index 068e62ae..690960a7 100644
--- a/src/slskd/Program.cs
+++ b/src/slskd/Program.cs
@@ -494,11 +494,10 @@ namespace slskd
var app = builder.Build();
- var migrator = app.Services.GetService<Migrator>();
-
- if (migrator is not null)
+ if (!OptionsAtStartup.Flags.Volatile)
{
- migrator.Migrate(force: OptionsAtStartup.Flags.ForceMigrations);
+ // note: if this ever throws, we've forgotten to register a Migrator following database DI config
+ app.Services.GetService<Migrator>().Migrate(force: OptionsAtStartup.Flags.ForceMigrations);
}
// hack: services that exist only to subscribe to the event bus are not referenced by anything else
@@ -606,7 +605,9 @@ namespace slskd
// we're working with non-volatile database files, so register a Migrator to be used later in the
// bootup process. the presence of a Migrator instance in DI determines whether a migration is needed.
- services.AddSingleton<Migrator>(_ => new Migrator());
+ // it's important that we keep this list of databases in sync with those used by the application; anything
+ // not in this list will not be able to be migrated.
+ services.AddSingleton<Migrator>(_ => new Migrator(databases: ["search", "transfers", "messaging", "events"]));
}
services.AddSingleton<EventService>();