Fix: Migrations are now done once with a specialised container instead of startup
All checks were successful
.NET Tests / test (push) Successful in 1m32s
All checks were successful
.NET Tests / test (push) Successful in 1m32s
This commit is contained in:
parent
a9de9c3a4c
commit
a8f978b82b
@ -54,6 +54,21 @@ services:
|
|||||||
networks:
|
networks:
|
||||||
- DB-Network
|
- 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:
|
networks:
|
||||||
DB-Network:
|
DB-Network:
|
||||||
driver: bridge
|
driver: bridge
|
||||||
|
|||||||
@ -14,10 +14,6 @@ builder.Services.AddControllers();
|
|||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
using var scope = app.Services.CreateScope();
|
|
||||||
var dbContext = scope.ServiceProvider.GetRequiredService<StreetDbContext>();
|
|
||||||
dbContext.Database.Migrate();
|
|
||||||
|
|
||||||
app.UseRouting();
|
app.UseRouting();
|
||||||
app.MapControllers();
|
app.MapControllers();
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user