mycroforge/MycroForge.CLI/Commands/MycroForge.Orm.Rollback.cs

29 lines
782 B
C#

using System.CommandLine;
using MycroForge.CLI.Commands.Interfaces;
namespace MycroForge.CLI.Commands;
public partial class MycroForge
{
public partial class Orm
{
public class Rollback : Command, ISubCommandOf<Orm>
{
private readonly ProjectContext _context;
public Rollback(ProjectContext context) : base("rollback", "Rollback the last migration")
{
_context = context;
this.SetHandler(ExecuteAsync);
}
private async Task ExecuteAsync()
{
await _context.Bash([
"source .venv/bin/activate",
"alembic downgrade -1"
]);
}
}
}
}