All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #1
40 lines
1.0 KiB
C#
40 lines
1.0 KiB
C#
using Infrastructure.Database;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace SchengenVisaApi;
|
|
|
|
#pragma warning disable CS1591
|
|
public class Program
|
|
{
|
|
private const string MigrationKey = "--migrate";
|
|
|
|
public static async Task Main(string[] args)
|
|
{
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
builder.RegisterServices();
|
|
builder.Services.AddHealthChecks();
|
|
|
|
var app = builder.Build();
|
|
|
|
await HandleMigrationKey(args, app);
|
|
|
|
app.ConfigurePipelineRequest();
|
|
app.UseHealthChecks("/health");
|
|
|
|
await app.RunAsync();
|
|
}
|
|
|
|
private static async Task HandleMigrationKey(string[] args, WebApplication app)
|
|
{
|
|
if (true)
|
|
{
|
|
using var scope = app.Services.CreateScope();
|
|
await using var context = scope.ServiceProvider.GetRequiredService<DatabaseContext>();
|
|
await context.Database.MigrateAsync();
|
|
// Environment.Exit(0);
|
|
Console.WriteLine("Migrations applied!");
|
|
}
|
|
}
|
|
}
|
|
#pragma warning restore CS1591
|