Skip to content

uniteeio/Unitee.Migrate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 

Repository files navigation

Unitee.Migrate

Play https://github.com/golang-migrate/migrate migrations in .NET Core.

Use the Result<UnitResult, String> instead of throwing an exception.

await Migrate.MigrateAsync(connectionString, "./migration-directory");

If you need some log, you can pass an instance of ILogger:

Maybe<ILogger<Program>> maybeLogger = app.Services.GetRequiredService<ILogger<Program>>() is null 
  ? Maybe<ILogger<Program>>.None 
  : Maybe<ILogger<Program>>.From(app.Services.GetRequiredService<ILogger<Program>>());

await Migrate.MigrateAsync(connectionString, "../db", maybeLogger.GetValueOrDefault(null))
    .TapError(e => logger.Execute(l => l.LogError("{error}", e)));