MSTKit.MigrationRunner
1.0.1
See the version list below for details.
dotnet add package MSTKit.MigrationRunner --version 1.0.1
NuGet\Install-Package MSTKit.MigrationRunner -Version 1.0.1
<PackageReference Include="MSTKit.MigrationRunner" Version="1.0.1" />
<PackageVersion Include="MSTKit.MigrationRunner" Version="1.0.1" />
<PackageReference Include="MSTKit.MigrationRunner" />
paket add MSTKit.MigrationRunner --version 1.0.1
#r "nuget: MSTKit.MigrationRunner, 1.0.1"
#:package MSTKit.MigrationRunner@1.0.1
#addin nuget:?package=MSTKit.MigrationRunner&version=1.0.1
#tool nuget:?package=MSTKit.MigrationRunner&version=1.0.1
MSTKit.MigrationRunner
An elegant, enterprise-grade, standalone FluentMigrator runner powered by Spectre.Console.
MSTKit.MigrationRunner wraps the standard FluentMigrator engine in a beautiful, interactive CLI with a modern "DevOps Classic" color palette. Say goodbye to boring, unreadable database migration logs!
✨ Features
- Beautiful UI: Replaces standard console output with highlighted SQL syntax, transaction states, and execution times using Spectre.Console.
- Auto-Database Creation: Automatically detects if the target SQL Server database exists and creates it if it doesn't.
- Idiot-Proof Configuration: Provides clear, visual error panels if
appsettings.jsonor connection strings are missing. - Interactive & Headless Modes: Perfect for both local development (interactive prompts) and CI/CD pipelines (headless execution).
- Safe Rollbacks: Easily rollback the last migration or revert to a specific version safely.
📦 Installation
Install the package via NuGet Package Manager Console:
Install-Package MSTKit.MigrationRunner
Or via the .NET Core command-line interface:
dotnet add package MSTKit.MigrationRunner
🚀 Quick Start
1. Configure your Application
In your target project (e.g., a Console App), simply call the MigrationCli.Run method and pass your arguments and the assembly containing your FluentMigrator migration classes.
using System.Reflection;
using MSTKit.MigrationRunner;
namespace YourApp.DatabaseSetup;
public class Program
{
public static void Main(string[] args)
{
// Pass CLI arguments and the assembly containing your migrations
MigrationCli.Run(args, Assembly.GetExecutingAssembly());
}
}
2. Add Configuration
Create an appsettings.json file in the root of your executable project. Ensure its properties are set to "Copy to Output Directory: Copy if newer".
{
"PersistenceConfig": {
"ConnectionString": "Server=localhost;Database=MyAwesomeDb;User Id=sa;Password=YourPassword123!;TrustServerCertificate=True"
}
}
3. Write a Migration
Create a standard FluentMigrator class in your project:
using FluentMigrator;
namespace YourApp.DatabaseSetup.Migrations;
[Migration(202610171200)]
public class InitialMigration : Migration
{
public override void Up()
{
Create.Table("Users")
.WithColumn("Id").AsInt32().PrimaryKey().Identity()
.WithColumn("Username").AsString(50).NotNullable();
}
public override void Down()
{
Delete.Table("Users");
}
}
🛠️ CLI Usage
Run your application from the terminal. If you run it without arguments, it will present a beautiful interactive menu.
Interactive Menu
dotnet run
Prompts you to choose: Migrate UP, Rollback 1 step, Rollback to version, or Cancel.
Non-Interactive (CI/CD Pipelines)
You can bypass the interactive menu by passing arguments (great for GitHub Actions / Docker):
Migrate Up to Latest:
dotnet run -- --autoRollback 1 Step:
dotnet run -- --rollback # or dotnet run -- -rRollback to Specific Version:
dotnet run -- --target=202610171200 --autoRun without waiting for user input at the end:
dotnet run -- --no-wait
📄 License
This project is licensed under the MIT License. See the LICENSE file for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- FluentMigrator.Runner (>= 8.0.1)
- Microsoft.Extensions.Configuration (>= 10.0.13)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.13)
- Microsoft.Extensions.Configuration.CommandLine (>= 10.0.13)
- Microsoft.Extensions.Configuration.EnvironmentVariables (>= 10.0.13)
- Microsoft.Extensions.Configuration.FileExtensions (>= 10.0.13)
- Microsoft.Extensions.Configuration.Json (>= 10.0.13)
- Spectre.Console (>= 0.57.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.