mycroforge/MycroForge.CLI/Commands/MycroForge.Db.Migrate.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 Db
{
public class Migrate : Command, ISubCommandOf<Db>
{
private readonly ProjectContext _context;
public Migrate(ProjectContext context) : base("migrate", "Apply migrations to the database")
{
_context = context;
this.SetHandler(ExecuteAsync);
}
private async Task ExecuteAsync()
{
await _context.Bash([
"source .venv/bin/activate",
"alembic upgrade head"
]);
}
}
}
}