LowCodeHub.Migration.SqlServer
0.0.1
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package LowCodeHub.Migration.SqlServer --version 0.0.1
NuGet\Install-Package LowCodeHub.Migration.SqlServer -Version 0.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LowCodeHub.Migration.SqlServer" Version="0.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LowCodeHub.Migration.SqlServer" Version="0.0.1" />
<PackageReference Include="LowCodeHub.Migration.SqlServer" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add LowCodeHub.Migration.SqlServer --version 0.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: LowCodeHub.Migration.SqlServer, 0.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package LowCodeHub.Migration.SqlServer@0.0.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=LowCodeHub.Migration.SqlServer&version=0.0.1
#tool nuget:?package=LowCodeHub.Migration.SqlServer&version=0.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
LowCodeHub.Migration.SqlServer
LowCodeHub.Migration.SqlServer provides a simple startup migration runner for SQL Server using embedded .sql scripts and deterministic execution order.
What this package does
- Runs SQL scripts from embedded resources.
- Orders scripts by Unix timestamp prefix in file name.
- Supports normal (journaled) scripts and always-execute scripts.
- Fails fast on invalid script naming or missing scripts (by default).
Install
dotnet add package LowCodeHub.Migration.SqlServer
Quick Start
using LowCodeHub.Migration.SqlServer.Extensions;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddMigration(builder.Configuration, sectionName: "Migration");
var app = builder.Build();
await app.RunDatabaseMigrationAsync<Program>(); // optional token overload exists
app.Run();
Configuration
{
"Migration": {
"ConnectionString": "Server=.;Database=MyDb;Trusted_Connection=True;Encrypt=False",
"Directories": [ "MyApp.Migrations.Scripts" ],
"AlwaysExecuteDirectories": [ "MyApp.Migrations.Always" ],
"FailOnNoScriptsFound": true
}
}
Script Naming Rules (Strict)
Scripts must start with a Unix-time numeric prefix:
- Valid:
1766733156_create_users.sql - Valid:
1766733160_add_index.sql - Invalid:
create_users.sql(no prefix) - Invalid:
v1_create_users.sql(prefix not numeric)
If naming is invalid, migration throws with a clear format error.
Ordering
- Ordering is based on the numeric prefix in the script file name.
- Folder name is used only for filtering (which scripts to include), not for ordering.
- If two scripts share the same numeric prefix, secondary ordering is by script name.
Journal vs Always Execute
- Scripts in
Directoriesare journaled (run once; tracked by DbUp journal). - Scripts in
AlwaysExecuteDirectoriesrun every startup (not journaled).
This is useful for:
- permissions grants
- view/procedure refresh scripts
- maintenance scripts that should always re-apply
Failure and Transactions
- Scripts execute one by one.
- Each script runs in its own transaction.
- If a script fails:
- that script is rolled back
- migration stops immediately
- next scripts are not executed
Cancellation
You can pass an optional cancellation token:
await app.RunDatabaseMigrationAsync<Program>(app.Lifetime.ApplicationStopping);
Cancellation is checked between script executions.
Best Practices
- Keep script names immutable once merged.
- Use Unix seconds prefix for predictable order.
- Keep one concern per script (small and reversible where possible).
- Use
AlwaysExecuteDirectoriesonly for idempotent scripts. - Keep
FailOnNoScriptsFound = truein production.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- dbup-sqlserver (>= 7.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.