fix(jobengine): register startup migrations for orchestrator schema

Wire AddStartupMigrations so JobEngine converges the orchestrator schema
on fresh database or wiped volumes without manual bootstrap scripts.
Adds StellaOps.Infrastructure.Postgres.Migrations dependency.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
master
2026-03-09 07:53:24 +02:00
parent 354654ea84
commit 481a062a1a
3 changed files with 41 additions and 0 deletions

View File

@@ -2,6 +2,7 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Npgsql;
using StellaOps.Infrastructure.Postgres.Migrations;
using StellaOps.JobEngine.Core.Backfill;
using StellaOps.JobEngine.Core.DeadLetter;
using StellaOps.JobEngine.Core.Observability;
@@ -54,6 +55,12 @@ public static class ServiceCollectionExtensions
}
});
services.AddStartupMigrations<JobEngineServiceOptions>(
schemaName: "orchestrator",
moduleName: "JobEngine",
migrationsAssembly: typeof(JobEngineDataSource).Assembly,
connectionStringSelector: options => options.Database.ConnectionString);
// Register data source
services.AddSingleton<JobEngineDataSource>();

View File

@@ -20,6 +20,7 @@
<ItemGroup>
<ProjectReference Include="..\StellaOps.JobEngine.Core\StellaOps.JobEngine.Core.csproj"/>
<ProjectReference Include="..\..\..\__Libraries\StellaOps.Infrastructure.Postgres\StellaOps.Infrastructure.Postgres.csproj" />
<ProjectReference Include="..\..\..\Telemetry\StellaOps.Telemetry.Core\StellaOps.Telemetry.Core\StellaOps.Telemetry.Core.csproj"/>
<ProjectReference Include="..\..\..\Router/__Libraries/StellaOps.Messaging\StellaOps.Messaging.csproj" />
</ItemGroup>

View File

@@ -0,0 +1,33 @@
using FluentAssertions;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using StellaOps.JobEngine.Infrastructure;
using StellaOps.TestKit;
namespace StellaOps.JobEngine.Tests.Infrastructure;
public sealed class JobEngineInfrastructureRegistrationTests
{
[Trait("Category", TestCategories.Unit)]
[Fact]
public void AddJobEngineInfrastructure_RegistersStartupMigrationHost()
{
var configuration = new ConfigurationBuilder()
.AddInMemoryCollection(new Dictionary<string, string?>
{
["JobEngine:Database:ConnectionString"] = "Host=postgres;Database=stellaops;Username=postgres;Password=postgres"
})
.Build();
var services = new ServiceCollection();
services.AddLogging();
services.AddJobEngineInfrastructure(configuration);
services
.Where(descriptor => descriptor.ServiceType == typeof(IHostedService))
.Should()
.ContainSingle("clean-reset installs need JobEngine startup migrations to create the orchestrator schema before serving traffic");
}
}