Skip to content

Commit

Permalink
fix: make it compile and refactor into one extension method
Browse files Browse the repository at this point in the history
  • Loading branch information
CumpsD committed Feb 24, 2020
1 parent ebc881b commit b329bd8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
namespace Be.Vlaanderen.Basisregisters.ProjectionHandling.Runner.MigrationExtensions
{
using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;

public static class MigratorExtensions
Expand All @@ -9,5 +11,11 @@ public static void SetDefaultMigratorCommandTimeout(this DbContext context)
{
context.Database.SetCommandTimeout(new TimeSpan(1, 0, 0, 0));
}

public static Task MigrateAsync(this DbContext context, CancellationToken cancellationToken)
{
context.SetDefaultMigratorCommandTimeout();
return context.Database.MigrateAsync(cancellationToken);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,7 @@ await Policy
{
_logger.LogInformation("Running EF Migrations for {ContextType}", typeof(TContext).Name);
using (var migrationContext = _createContext())
{
migrationContext.SetDefaultCommandTimeout();
await migrationContext.Database.MigrateAsync(cancellationToken);
}
await migrationContext.MigrateAsync(cancellationToken);
},
cancellationToken
);
Expand Down

0 comments on commit b329bd8

Please sign in to comment.