Skip to content

Commit 013a90b

Browse files
authored
Merge branch 'main' into make-pollinginterval-configurable-for-kubernetes
2 parents be12a69 + 9d4c2d6 commit 013a90b

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

ClubService.API/Program.cs

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using ClubService.API;
22
using ClubService.API.ApplicationConfigurations;
3+
using ClubService.Domain.Repository;
34
using ClubService.Infrastructure.DbContexts;
45
using Microsoft.AspNetCore.Authentication;
56
using Microsoft.EntityFrameworkCore;
@@ -66,7 +67,16 @@
6667
app.UseSwaggerUI(options => { options.SwaggerEndpoint("/swagger/v1/swagger.json", "ClubServiceV1"); });
6768

6869
await eventStoreDbContext.Database.EnsureCreatedAsync();
69-
await eventStoreDbContext.SeedTestData();
70+
71+
try
72+
{
73+
await eventStoreDbContext.SeedTestData();
74+
}
75+
catch (DbUpdateException)
76+
{
77+
var logger = services.GetRequiredService<ILoggerService<Program>>();
78+
logger.LogDuplicateSeedData();
79+
}
7080

7181
await readStoreDbContext.Database.EnsureDeletedAsync();
7282
await readStoreDbContext.Database.EnsureCreatedAsync();

ClubService.Domain/Repository/ILoggerService.cs

+1
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,5 @@ public interface ILoggerService<T>
6464
void LogJsonMissingProperties(string jsonValue);
6565
void LogEmailMessageRelayStop();
6666
void LogSystemOperatorRegistered(Guid id);
67+
void LogDuplicateSeedData();
6768
}

ClubService.Infrastructure/Logging/LoggerService.cs

+5
Original file line numberDiff line numberDiff line change
@@ -320,4 +320,9 @@ public void LogSystemOperatorRegistered(Guid id)
320320
{
321321
logger.LogInformation("Registered system operator with id '{id}'.", id);
322322
}
323+
324+
public void LogDuplicateSeedData()
325+
{
326+
logger.LogInformation("Seed data already seeded");
327+
}
323328
}

0 commit comments

Comments
 (0)