Lilmihe.Lib
1.0.1
dotnet add package Lilmihe.Lib --version 1.0.1
NuGet\Install-Package Lilmihe.Lib -Version 1.0.1
<PackageReference Include="Lilmihe.Lib" Version="1.0.1" />
paket add Lilmihe.Lib --version 1.0.1
#r "nuget: Lilmihe.Lib, 1.0.1"
// Install Lilmihe.Lib as a Cake Addin #addin nuget:?package=Lilmihe.Lib&version=1.0.1 // Install Lilmihe.Lib as a Cake Tool #tool nuget:?package=Lilmihe.Lib&version=1.0.1
Little Migration Helper
Overview
Lilmihe is a versatile database migration tool designed to simplify the process of applying SQL scripts to a database. Whether integrated as a library into your .NET Core project or used as a standalone command-line application, Lilmihe provides a seamless solution for managing database migrations.
Features
- Automated Script Execution: Automatically detects and executes SQL scripts located in a specified directory.
- Transaction Management: Executes each script within a transaction to ensure atomicity. If an error occurs, changes are rolled back to maintain database integrity.
- Migration Tracking: Keeps track of applied migrations using a dedicated table in the database to avoid reapplying the same script.
- Error Handling: Captures and reports errors encountered during the migration process, including specific commands and files that failed.
Importing
To use Lilmihe as a library in your .NET project, install the NuGet package:
dotnet add package Lilmihe
Building the Tool from the Source Code
Requirements
- .NET SDK (version 8.0 or later)
- Git
Steps
- Clone the Repository:
git clone https://github.com/Rael-G/Lilmihe.git
cd Lilmihe
- Publish the Executable:
dotnet publish src/Lilmihe.Tool/Lilmihe.Tool.csproj
The compiled executable will be located in the artifacts/publish/Lilmihe.Tool/release/ directory. You can then use this executable to run the Tool application.
Usage
As a Library
Integrate Lilmihe into your .NET Core project to automate database migrations:
using Lilmihe;
using Microsoft.Data.Sqlite;
var scriptsPath = "path_to_your_scripts";
using var connection = new SqliteConnection("Data Source=database.db");
var migrator = new MigrationHelper(scriptsPath, connection);
var result = await migrator.Migrate();
if (result.Success)
{
Console.WriteLine("Migration completed successfully.");
}
else
{
Console.WriteLine($"Migration failed: {result.Message}");
if (result.Error != null)
{
Console.WriteLine($"File: {result.Error.Message}");
}
}
As a Command-Line Application
Use Lilmihe from the command line to execute database migrations:
lilmihe --sqlite -c "Your_Connection_String" -p "path_to_your_sql_scripts"
Migration Scripts
Place your SQL migration scripts in the specified directory. Scripts should be named in a way that reflects the order they should be applied (e.g., Migration_001_create_table.sql, Migration_002_add_column.sql, Seed_001_populate).
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. |
-
net8.0
- Dapper (>= 2.1.35)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.1 | 75 | 5/28/2024 |