Spaces:
Runtime error
Runtime error
Download src/SCM.Migrations/DependencyInjection.cs from rafaeldavila/scm-api: direct link, hf CLI and curl.
- Browser
- Download file 1.02 kB
-
https://huggingface.co/spaces/rafaeldavila/scm-api/resolve/main/src/SCM.Migrations/DependencyInjection.cs
- Command line
-
hf download hf://spaces/rafaeldavila/scm-api/src/SCM.Migrations/DependencyInjection.cs
-
curl -L -o DependencyInjection.cs https://huggingface.co/spaces/rafaeldavila/scm-api/resolve/main/src/SCM.Migrations/DependencyInjection.cs
1.02 kB
| 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(); | |
| } | |
| } | |