Spaces:
Runtime error
Runtime error
File size: 1,017 Bytes
de8b914 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | using FluentMigrator.Runner;
using Microsoft.Extensions.DependencyInjection;
using SCM.Migrations.Migrations;
namespace SCM.Migrations;
public static class DependencyInjection
{
public static IServiceCollection AddScmMigrations(this IServiceCollection services, string connectionString)
{
services
.AddFluentMigratorCore()
.ConfigureRunner(rb => rb
.AddPostgres()
.WithGlobalConnectionString(connectionString)
.ScanIn(typeof(M0001_InitialSchema).Assembly).For.Migrations())
.AddLogging(lb => lb.AddFluentMigratorConsole());
return services;
}
/// <summary>Aplica todas as migrations pendentes (MigrateUp). Chamar no startup, se habilitado.</summary>
public static void RunScmMigrations(this IServiceProvider provider)
{
using var scope = provider.CreateScope();
var runner = scope.ServiceProvider.GetRequiredService<IMigrationRunner>();
runner.MigrateUp();
}
}
|