Fix: Migrations are now done once with a specialised container instead of startup
All checks were successful
.NET Tests / test (push) Successful in 1m32s

This commit is contained in:
Jonas Seiler 2025-04-03 18:34:17 +02:00
parent a9de9c3a4c
commit a8f978b82b
2 changed files with 15 additions and 4 deletions

View File

@ -54,6 +54,21 @@ services:
networks:
- DB-Network
migrate:
image: mcr.microsoft.com/dotnet/sdk:9.0
working_dir: /streets
volumes:
- .:/streets
entrypoint: ["sh", "-c", "dotnet tool install --global dotnet-ef && dotnet ef database update --project src/"]
environment:
PATH: "/root/.dotnet/tools:$PATH"
CONNECTION_STRING: "Host=postgis-db;Port=5432;Username=postgres;Password=password;Database=streets_db;"
depends_on:
- postgis-db
networks:
- DB-Network
restart: "no"
networks:
DB-Network:
driver: bridge

View File

@ -14,10 +14,6 @@ builder.Services.AddControllers();
var app = builder.Build();
using var scope = app.Services.CreateScope();
var dbContext = scope.ServiceProvider.GetRequiredService<StreetDbContext>();
dbContext.Database.Migrate();
app.UseRouting();
app.MapControllers();