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:
@@ -2,6 +2,7 @@
|
|||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Npgsql;
|
using Npgsql;
|
||||||
|
using StellaOps.Infrastructure.Postgres.Migrations;
|
||||||
using StellaOps.JobEngine.Core.Backfill;
|
using StellaOps.JobEngine.Core.Backfill;
|
||||||
using StellaOps.JobEngine.Core.DeadLetter;
|
using StellaOps.JobEngine.Core.DeadLetter;
|
||||||
using StellaOps.JobEngine.Core.Observability;
|
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
|
// Register data source
|
||||||
services.AddSingleton<JobEngineDataSource>();
|
services.AddSingleton<JobEngineDataSource>();
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\StellaOps.JobEngine.Core\StellaOps.JobEngine.Core.csproj"/>
|
<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="..\..\..\Telemetry\StellaOps.Telemetry.Core\StellaOps.Telemetry.Core\StellaOps.Telemetry.Core.csproj"/>
|
||||||
<ProjectReference Include="..\..\..\Router/__Libraries/StellaOps.Messaging\StellaOps.Messaging.csproj" />
|
<ProjectReference Include="..\..\..\Router/__Libraries/StellaOps.Messaging\StellaOps.Messaging.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -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");
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user