datntdev.SchemaVersioner
1.1.1
See the version list below for details.
dotnet add package datntdev.SchemaVersioner --version 1.1.1
NuGet\Install-Package datntdev.SchemaVersioner -Version 1.1.1
<PackageReference Include="datntdev.SchemaVersioner" Version="1.1.1" />
<PackageVersion Include="datntdev.SchemaVersioner" Version="1.1.1" />
<PackageReference Include="datntdev.SchemaVersioner" />
paket add datntdev.SchemaVersioner --version 1.1.1
#r "nuget: datntdev.SchemaVersioner, 1.1.1"
#:package datntdev.SchemaVersioner@1.1.1
#addin nuget:?package=datntdev.SchemaVersioner&version=1.1.1
#tool nuget:?package=datntdev.SchemaVersioner&version=1.1.1
datntdev - SchemaVersioner
datntdev.SchemaVersioner provides a robust solution for database schema management, ensuring that changes are applied consistently across different environments. It supports versioned migrations to track incremental changes and repeatable migrations for objects like views or stored procedures that might be updated frequently. The tool is designed to work on various database engines.
Core Components
datntdev.SchemaVersioner: The core class library (found insrc/datntdev.SchemaVersioner/) containing the logic for discovering, tracking, and applying database migrations. This package can be installed into your .NET Application which provides a programmatically approach to migrate your databases from your application.datntdev.SchemaVersioner.Cli: A command-line interface (CLI) tool (found insrc/datntdev.SchemaVersioner.Cli/) that utilizes the core library to perform schema versioning operations. This allows for easy integration into build and deployment pipelines.
Key Features
- Initialize New Database: Set up a new database using snapshot scripts.
- Erase Database: Completely clear a database (use with extreme caution).
- Validate Migrations: Check consistency between migration scripts and metadata.
- Repair Metadata: Reconcile the metadata table based on available migration scripts.
- Targeted Versioning: Upgrade or downgrade to a specific database version.
- Migrate to Latest: Apply all pending migrations to bring the database to the most recent version.
- Schema Snapshot Generation: Create scripts representing the current schema for supported databases.
- CLI Tool for CI/CD Pipeline: Easily script and automate database migration processes.
Supported Database Engines
| Database | Initialize Command | Erase Command | Validate Command | Repair Command | Upgrade Command | Downgrade Command | Snapshot Command |
|---|---|---|---|---|---|---|---|
| SQLite | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| MsSQL | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Ms Fabric | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| PostgreSQL | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
Getting Started
Prerequisites
- For development with Nuget Package: .NET SDK 8.0 or later
- For CLI tool usage: Windows - 64bit
Installation
CLI Tool: Download the appropriate version for your platform from latest release
Nuget Package: For using the library in your project
dotnet add package datntdev.SchemaVersioner
Getting Started with CLI
A simple example of SQLite database which init a new database with a snapshot script. This command will initialize the database with the schema defined in the snapshot scripts located in Resources/SQLite/Snapshots and apply any migrations found in Resources/SQLite/Migrations as a metadata table to avoid running all migration versions for the next time of upgrade version.
datntdev.SchemaVersioner.Cli.exe --database-type=sqlite ^
--connection-string="Data Source=Resources/SQLite/database.db;Cache=Shared" ^
--migration-paths="Resources/SQLite/Migrations" ^
--snapshot-paths="Resources/SQLite/Snapshots" ^
init
Getting Started with Library
To use the datntdev.SchemaVersioner library in your .NET application, you can follow these steps:
try
{
var logger = LoggerFactory.Create(builder => builder.AddSimpleConsole()).CreateLogger<SchemaVersioner>();
var dbConnection = new SqliteConnection(SQLiteConnectionString);
var versioner = new SchemaVersioner(dbConnection, logger,
new SchemaVersionerOptions
{
MigrationPaths = new[] { "Resources/SQLite/Migrations" },
SnapshotPaths = new[] { "Resources/SQLite/Snapshots" }
});
// Initialize a new database with snapshot scripts
versioner.Init();
}
catch (Exception ex)
{
Console.WriteLine($"An error occurred: {ex.Message}");
// Handle exceptions as needed
}
Concepts
TBD: Detailed explanation of concepts like versioned migrations, repeatable migrations, and how they are applied in different database engines.
License
This project is licensed under the MIT License. See the LICENSE file for full 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 is compatible. 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
- ConsoleTables (>= 2.6.2)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.5)
- Microsoft.SqlServer.SqlManagementObjects (>= 172.76.0)
- Npgsql (>= 9.0.3)
-
net9.0
- ConsoleTables (>= 2.6.2)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.5)
- Microsoft.SqlServer.SqlManagementObjects (>= 172.76.0)
- Npgsql (>= 9.0.3)
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.2.0-prerelease.20260203 | 4,138 | 2/3/2026 |
| 1.2.0-prerelease.20250930 | 156 | 9/30/2025 |
| 1.2.0-prerelease.20250920 | 5,419 | 9/20/2025 |
| 1.2.0-beta.20250920 | 182 | 9/20/2025 |
| 1.1.1 | 405 | 9/19/2025 |
| 1.1.1-beta.20250919 | 209 | 9/19/2025 |
| 1.1.0 | 150 | 6/29/2025 |
| 1.0.1 | 195 | 6/16/2025 |
| 1.0.0 | 198 | 6/15/2025 |
| 1.0.0--beta.20250616 | 967 | 6/16/2025 |
| 1.0.0--beta.20250615 | 141 | 6/15/2025 |
| 1.0.0--beta.20250614 | 131 | 6/14/2025 |
| 1.0.0--beta.20250612 | 302 | 6/12/2025 |