fix: make development database seeding reliable

This commit is contained in:
2026-07-30 10:03:45 +08:00
parent 98585aa521
commit bf370605d4
3 changed files with 9 additions and 0 deletions

View File

@@ -8,6 +8,7 @@ using Tiku.Infrastructure;
using Tiku.Infrastructure.Persistence;
using Tiku.Infrastructure.Bootstrap;
using Tiku.Application;
using Tiku.Application.Security;
var builder = Host.CreateApplicationBuilder(args);
builder.Logging.AddFilter("Microsoft.EntityFrameworkCore", LogLevel.Warning);
@@ -47,6 +48,8 @@ builder.Services.AddDataProtection().UseEphemeralDataProtectionProvider();
using var host = builder.Build();
await using var scope = host.Services.CreateAsyncScope();
scope.ServiceProvider.GetRequiredService<ITenantContextInitializer>()
.InitializeSystem(null, "Database migration and bootstrap");
var dbContext = scope.ServiceProvider.GetRequiredService<TikuDbContext>();
await dbContext.Database.MigrateAsync();
var catalogSeeder = ActivatorUtilities.CreateInstance<BuiltinBackofficeCatalogSeeder>(scope.ServiceProvider);