![]() |
VOOZH | about |
dotnet tool install --global migtool --version 9.1.0
dotnet new tool-manifestif you are setting up this repo
dotnet tool install --local migtool --version 9.1.0
#tool dotnet:?package=migtool&version=9.1.0
nuke :add-package migtool --version 9.1.0
👁 .NET
👁 F#
👁 License: Apache2
👁 NuGet Version
👁 NuGet Downloads
👁 Tests
Migrate is a SQLite-first migration toolchain built around a MigSchema project, generated Db.fs, and compiled schema modules.
It generates typed CRUD/query helpers from compiled schema definitions and provides blocking init, plan, migrate, status, and reset workflows for schema-bound SQLite files.
The current convention is:
MigSchema/MigSchema.fsproj.MigSchema/Main.fs.mig codegen from the runtime project directory.mig codegen write Db.fs into the schema directory.Every schema module must be marked with the same GeneratedDbNamespace:
[<MigLib.Dsl.Attributes.GeneratedDbNamespace("MyApp")>]
module MyApp.MigSchema.Main
mig codegen merges all attributed modules into one generated MyApp.Db module and derives the SQLite filename prefix from the shared namespace value.
mig codegen emits a runtime module that contains:
GeneratedSchemaExamples of generated helpers include:
Student.InsertStudent.InsertOrIgnoreStudent.SelectByIdStudent.SelectAllStudent.SelectByNameStudent.SelectNameLikeStudent.SelectAdultsStudent.DeleteAdultsStudent.SelectByNameOrInsertStudent.UpsertInstall the CLI as a global tool:
dotnet tool install --global migtool
For library usage:
MigLib for schema attributes, generated CRUD support, transactions, and migration workflowsMigLib.Web when you also want the ASP.NET Core webResult helpersBuild and install the current branch as a global mig tool from the local package output:
dotnet fsi build.fsx install
Build the schema project, generate Db.fs, build the runtime project, and initialize the schema-bound database:
dotnet build ./my-app/MigSchema/MigSchema.fsproj
mig codegen -d ./my-app
dotnet build ./my-app/my-app.fsproj
mig init -d ./my-app
mig init is idempotent at the workflow level: when the target database already exists, it reports success and does not recreate it.
When a previous schema-bound SQLite file already exists for the same app/instance prefix, mig migrate creates the new target database, copies compatible data, and archives the old file into archive/ next to the database directory.
dotnet build ./my-app/MigSchema/MigSchema.fsproj
mig codegen -d ./my-app
dotnet build ./my-app/my-app.fsproj
mig plan -d ./my-app
mig migrate -d ./my-app
mig status -d ./my-app
If you need to discard the current target database and restore the latest archived database back into the main database directory:
mig reset -d ./my-app
Generated helpers execute inside dbTxn or txn transaction workflows.
open System.IO
open MigLib
open MigLib.MigProject
open MyApp.Db
let project =
MigProject.Mig.resolveFromGeneratedSchema dataDirectory None GeneratedSchema
|> fun task -> task.Result
|> Result.defaultWith (fun error -> failwithf "%A" error)
let db = dbTxn project.targetDbPath
let result =
db {
let! student = Student.SelectByNameOrInsert { Id = 0L; Name = "Alice"; Age = 21L }
let! matches = Student.SelectNameLike "li"
return student, matches
}
example/ shows the full convention in a working project:
example/example.fsprojexample/MigSchema/MigSchema.fsprojDb.fs at example/MigSchema/Db.fsexample/Program.fsinit and migrate flows in example/build.fsxRun it with:
dotnet fsi example/build.fsx
mig codegen: generate Db.fs from the compiled MigSchema schema modulesmig init: create the current schema-bound database when it does not exist yetmig plan: report inferred source/target paths plus supported and unsupported schema differencesmig migrate: create the target database, copy data, and archive the previous source databasemig status: show the current database path, archived databases, and whether a migration source is still presentmig reset: delete the current target database and restore the latest archived database into the main database directory| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package has no dependencies.
| Version | Downloads | Last Updated |
|---|---|---|
| 9.1.0 | 105 | 6/2/2026 |
| 9.0.0 | 114 | 6/1/2026 |
| 8.3.0 | 98 | 5/29/2026 |
| 8.2.0 | 98 | 5/29/2026 |
| 8.1.1 | 113 | 5/28/2026 |
| 8.1.0 | 130 | 5/28/2026 |
| 8.0.4 | 119 | 5/26/2026 |
| 8.0.3 | 120 | 5/26/2026 |
| 8.0.2 | 124 | 5/24/2026 |
| 8.0.1 | 118 | 5/23/2026 |
| 8.0.0 | 118 | 5/17/2026 |
| 7.0.2 | 137 | 4/14/2026 |
| 7.0.1 | 120 | 4/14/2026 |
| 7.0.0 | 136 | 4/11/2026 |
| 6.0.1 | 132 | 4/10/2026 |
| 6.0.0 | 118 | 4/10/2026 |
| 5.4.0 | 116 | 4/7/2026 |
| 5.3.0 | 121 | 4/7/2026 |
| 5.2.9 | 128 | 4/3/2026 |
| 5.2.8 | 119 | 4/3/2026 |