1
This commit is contained in:
16
Yes.Application/Migrators/MigrateDownCommandHandler.cs
Normal file
16
Yes.Application/Migrators/MigrateDownCommandHandler.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
namespace Yes.Application.Migrators
|
||||
{
|
||||
public record MigrateDownCommand(long Version) : IRequest<Unit>;
|
||||
|
||||
public class MigrateDownCommandHandler(IMigratorProvider migratorProvider) : IRequestHandler<MigrateDownCommand, Unit>
|
||||
{
|
||||
private readonly IMigratorProvider _migratorProvider = migratorProvider;
|
||||
|
||||
public async Task<Unit> Handle(MigrateDownCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
_migratorProvider.MigrateDown(request.Version);
|
||||
|
||||
return await Task.FromResult(new Unit());
|
||||
}
|
||||
}
|
||||
}
|
||||
16
Yes.Application/Migrators/MigrateUpCommandHandler.cs
Normal file
16
Yes.Application/Migrators/MigrateUpCommandHandler.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
namespace Yes.Application.Migrators
|
||||
{
|
||||
public record MigrateUpCommand(long? Version) : IRequest<Unit>;
|
||||
|
||||
public class MigrateUpCommandHandler(IMigratorProvider migratorProvider) : IRequestHandler<MigrateUpCommand, Unit>
|
||||
{
|
||||
private readonly IMigratorProvider _migratorProvider = migratorProvider;
|
||||
|
||||
public async Task<Unit> Handle(MigrateUpCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
_migratorProvider.MigrateUp(request.Version, ensureDatabase: true);
|
||||
|
||||
return await Task.FromResult(new Unit());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user