feat: auto-create inventory records for new products + migration worker
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 8m52s
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 8m52s
- CreateNewProductsCommandHandler: inject IInventoryService, auto-init inventory record with qty=0 when a new regular product is created (DiscountProduct handler already had this) - InventoryInitializerService: one-time BackgroundService that runs on startup, finds existing products without InventoryItem records, and creates them (migration for legacy products) - Register InventoryInitializerService in DI
This commit is contained in:
@@ -123,6 +123,9 @@ public static class ConfigureServices
|
||||
// Expire pending discount orders after 30 minutes
|
||||
services.AddHostedService<ExpirePendingOrdersService>();
|
||||
|
||||
// One-time: Initialize inventory records for existing products
|
||||
services.AddHostedService<InventoryInitializerService>();
|
||||
|
||||
if (configuration.GetValue<bool>("UseInMemoryDatabase"))
|
||||
{
|
||||
services.AddDbContext<ApplicationDbContext>(options =>
|
||||
|
||||
Reference in New Issue
Block a user