MigLib 3.0.0

dotnet add package MigLib --version 3.0.0
                    
NuGet\Install-Package MigLib -Version 3.0.0
                    
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="MigLib" Version="3.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MigLib" Version="3.0.0" />
                    
Directory.Packages.props
<PackageReference Include="MigLib" />
                    
Project file
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 MigLib --version 3.0.0
                    
#r "nuget: MigLib, 3.0.0"
                    
#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 MigLib@3.0.0
                    
#: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=MigLib&version=3.0.0
                    
Install as a Cake Addin
#tool nuget:?package=MigLib&version=3.0.0
                    
Install as a Cake Tool

logo

.NET F# License: Apache2 NuGet Version NuGet Downloads Tests

Migrate is a SQLite-first migration toolchain built around F# schema scripts (.fsx). It provides a hot-migration workflow (migratedraincutover) plus type-safe code generation from reflected schema types.

Installation

If you just want to test the tool without installing .Net, then you can use a Docker image:

podman run -it 'mcr.microsoft.com/dotnet/sdk:10.0' bash

Inside the container run:

export PATH="$PATH:/root/.dotnet/tools"

After having .Net in your system you can run

dotnet tool install --global migtool

Local Tool Build/Install (FAKE)

Build, pack, and install the current branch as a global mig tool from the local package output:

dotnet fsi build.fsx

Run specific FAKE targets when needed:

dotnet fsi build.fsx -- --target Build
dotnet fsi build.fsx -- --target PackTool

Run the installed local tool directly:

mig --help

Quickstart (Online Migration)

Assuming:

  • an existing SQLite database named <dir>-<old-hash>.sqlite
  • a target schema script at schema.fsx
# from your project directory:
# - expects ./schema.fsx
# - expects exactly one source db matching <dir>-<old-hash>.sqlite
# - derives target db as <dir>-<schema-hash>.sqlite
mig plan
mig migrate

# then continue in the same directory (paths auto-resolve)
mig status
mig drain
mig cutover
# optional, after traffic has fully moved to the new service:
mig cleanup-old

# from a different directory:
mig migrate -d /path/to/project

# if migrate fails and you need to clear failed migration artifacts:
mig reset --dry-run
mig reset

Quickstart (Schema Initialization)

When you want to bootstrap a database directly from schema.fsx (no source DB yet):

# from your project directory:
# - expects ./schema.fsx
# - derives db path as <dir>-<schema-hash>.sqlite
mig init

Features

  • F# schema reflection from .fsx scripts
  • FK-aware bulk copy and replay with ID mapping
  • Replay checkpoints and drain safety validation
  • Schema identity metadata (schema_hash, optional schema_commit) persisted in new database
  • Operational status reporting for old/new database migration state
  • Optional old-database migration-table cleanup after cutover

Specs

Commands

  • mig init [--dir|-d <path>] - Create a schema-matched database from schema.fsx and apply seed inserts (no source DB required).
  • mig codegen [--dir|-d <path>] [--module|-m <name>] [--output|-o <file>] - Generate F# query helpers from schema.fsx into a file in the same directory as the schema.
  • mig migrate [--dir|-d <path>] - Create the new DB from schema, copy data, and start recording on old DB.
  • mig plan [--dir|-d <path>] - Print dry-run inferred paths, schema diff summary, and replay prerequisites without mutating DBs.
  • mig drain [--dir|-d <path>] - Switch old DB to draining mode and replay pending migration log entries.
  • mig cutover [--dir|-d <path>] - Verify drain completion plus old marker/log replay safety, switch new DB to ready, and remove replay-only tables.
  • mig cleanup-old [--dir|-d <path>] - Optional cleanup of old DB migration tables (_migration_marker, _migration_log).
  • mig reset [--dir|-d <path>] [--dry-run] - Reset failed/aborted migration artifacts, or inspect reset impact without mutating DB files.
  • mig status [--dir|-d <path>] - Show marker/status state and migration counters for operational visibility.

Contributing

How to contribute:

  • Open an issue to discuss the change and approach
  • Add relevant tests
  • Create a pull request mentioning the issue and also including a summary of the problem and approach to solve it
  • Wait for the review

Acknowledgments

This project wouldn't have been possible without the amazing open-source community. We're especially grateful to:

  • Fabulous.AST - An elegant F# DSL for code generation that made creating and manipulating F# AST a joy
  • Fantomas - The excellent F# code formatter that ensures our generated code is beautiful and consistent

If you find these projects valuable, please consider supporting them:

  • Star their repositories
  • Contribute to their projects
  • Donate to support their continued development

License

Apache 2.0

Product 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.

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
3.0.0 32 3/7/2026
2.13.0 92 2/12/2026
2.12.1 88 2/11/2026
2.12.0 91 2/11/2026
2.11.0 91 2/10/2026
2.10.0 107 2/7/2026
2.9.1 93 2/6/2026
2.9.0 89 2/5/2026
2.8.0 92 2/3/2026
2.7.2 94 2/2/2026
2.7.1 97 2/2/2026
2.7.0 103 1/31/2026
2.6.0 100 1/26/2026
2.5.0 102 1/14/2026
2.4.0 99 1/14/2026
2.3.0 104 1/14/2026
2.0.0 103 1/13/2026
1.0.4 281 3/4/2025
1.0.3 143 1/11/2025
1.0.2 148 1/11/2025