Вытащил солюшен на уровень выше, чтобы прощё было дотнетить
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
36
SchengenVisaApi/Program.cs
Normal file
36
SchengenVisaApi/Program.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
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();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
await HandleMigrationKey(args, app);
|
||||
|
||||
app.ConfigurePipelineRequest();
|
||||
|
||||
await app.RunAsync();
|
||||
}
|
||||
|
||||
private static async Task HandleMigrationKey(string[] args, WebApplication app)
|
||||
{
|
||||
if (args.Contains(MigrationKey))
|
||||
{
|
||||
using var scope = app.Services.CreateScope();
|
||||
await using var context = scope.ServiceProvider.GetRequiredService<DatabaseContext>();
|
||||
await context.Database.MigrateAsync();
|
||||
Environment.Exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore CS1591
|
||||
Reference in New Issue
Block a user