Current version: 0.3.0

Changelog

0.3.0

Minor release: a new command surface and a ledger schema migration, plus a public type that changes in a way that breaks code built against 0.2. The CLI gains migratr dev, up --smuggl, down --smuggl, --discover, the migratr.jsonc settings file and --config. LedgerRow gains the public fields up_hash and down_hash, and it is not #[non_exhaustive], so a ^0.2 dependent that builds a LedgerRow literal would fail to compile against a 0.2.x. The ledger's schema changes: the next up, down, record_applied or record_note on a database whose _migratr_migrations lacks them runs ALTER TABLE _migratr_migrations ADD COLUMN up_hash TEXT and ... ADD COLUMN down_hash TEXT, inside the same atomic run as the first migration it applies or reverts, and keeps every existing row. Rows written before this release keep NULL hashes. Ledger versions 0 and 1 are now reserved for notes, and the ledger readers leave them out, so a migration numbered 0 or 1 would no longer be seen. Migration versions are timestamps, so no real migration takes those numbers. The migration file format is unchanged and every existing file keeps its checksum. Every crate now declares rust-version = "1.89", a new minimum toolchain, because rusqlite 0.41 needs it. The rusqlite feature is on by default, RusqliteExecutor::new takes a rusqlite::Connection, and libsqlite3-sys links sqlite3, so only one version of it can be in a build: a dependent that uses rusqlite anywhere in its graph must move to rusqlite 0.41 (libsqlite3-sys 0.39) with migratr.

The place release. migratr can now work against a remote database, the place, through the smugglr binary. migratr dev makes the local database from the place named by smuggl in migratr.jsonc and records that copy as a verified rewind point. migratr up --smuggl and migratr down --smuggl then ship the local migrations, or their reverts, to the place through that rewind point. The place can be a file, an https:// address or a d1:// database. A ship refuses to start when the place's shape changed outside migratr, rolls the local database back to the rewind point on any failure, and finishes the remaining work when run again. --discover reports what either command would do and changes nothing. To make the ship checkable, the ledger now records a hash of the statements each migration ran up and of the statements that revert it. A place with a full-text table works with both commands, and a place with an AUTOINCREMENT table is refused.

New

  • migratr dev copies the place and records a rewind point (PR #85, #78; PR #88, #79; PR #95, #94; PR #99, #86; PR #101, #100): dev reads the place with smugglr exec <place> --read. It then builds a new database in .migratr/dev beside the local one, in this order: the place's tables, its rows through smugglr sync (which honours smugglr's ignore list, so an ignored table arrives with its shape and no rows), the ledger's migration rows, and last the indexes, triggers and views. Because triggers come last, no trigger fires on a copied row. The new database is snapshotted as <time>_<version>_dev.db, and smugglr sync --dryrun must find that the snapshot and the new database move nothing. Then the new database's ledger records the rewind point as a JSON note naming the snapshot and its SHA-256, beside a fingerprint note that holds the place's structural fingerprint and the migration versions the place held. Only then is the old local database kept as a <time>_<version>_kept.db snapshot, its stale -wal and -shm files removed, and the new one renamed into place. dev takes its snapshots with VACUUM INTO, not a file copy, so writes still in a WAL are kept. Pruning never removes kept or dev snapshots. They do count toward latest_snapshot, so after dev the latest snapshot that status shows and restore picks by default is the rewind point, which sorts after any other snapshot of the same second. The first dev against a place that has tables but no migratr ledger adopts it only when its shape, compared by structure, is what the migrations make. That comparison covers columns, foreign keys, indexes, CHECK and UNIQUE items, and trigger and view text, each normalized for quoting, case and whitespace. On a match, dev records every migration. Otherwise it stops with not_adoptable, naming each difference by table. A later dev compares the place's fingerprint with the recorded one. If they differ, it stops with shape_changed and points to --discover. If they match, it carries only the migration rows the place held, so a migration applied locally since then reads as pending again. Every stop happens before anything changes. dev --discover prints smugglr sync --discover for the local database and the place. dev needs smugglr 0.6.3 or later, the first release with exec, found through SMUGGLR or else smugglr on the PATH. Without it, dev refuses with smugglr_missing and names the version to install. CI now installs smugglr v0.6.3 for the tests. A place with an AUTOINCREMENT table is refused with autoincrement, naming each such table, before anything changes, because migratr allows no auto columns. A full-text table comes down with its rows: virtual tables, those made with CREATE VIRTUAL TABLE, replay first, so each makes its own shadow tables, and the replay skips any object already made. A place written by VACUUM INTO lists a full-text table's shadow tables before the table, so this order is what lets such a place come down. A virtual table has no primary key to sync by, so dev adds the place's virtual tables to the ignore list of the smugglr config it runs with, and their rows arrive through the shadow tables. The first copy into the new database runs with --sync-mode source, so the place's shadow rows win. A table with a generated VIRTUAL column is an ordinary table and syncs its rows. A failed dev leaves the local database as it was. Because the rewind point is recorded before the new database replaces the local one, only the rename and the pair's memory in .migratr/pair come after it, and a failure from there puts the old local database back from its kept snapshot (or removes the new one when there was none) and puts back the old pair's memory, which dev sets aside first. A rewind point that never became the local database's is removed. A snapshot whose name is already taken in the same second waits for the next second, so no two snapshots share a name.
  • up --smuggl and down --smuggl ship through the rewind point (PR #90, #81; PR #92, #91; PR #93, #82; PR #99, #86; PR #101, #100): up --smuggl (honouring --to) and down --smuggl (honouring --steps) first check three things: that the rewind point's file still has the SHA-256 dev recorded, that the ledger holds a rewind point at all (otherwise no_rewind_point, telling you to run migratr dev), and that the place's fingerprint is the recorded one (otherwise shape_changed). Each check stops before anything changes. The run then snapshots the working database, puts the rewind point back at the local database's own path with both notes, and syncs it with the place through a copy of the memory dev left in .migratr/pair, so the place's inserts, updates and deletes since dev arrive while rows made only in the working database stay home. It applies or reverts the migrations one at a time and sends each one's statements, as migratr plan gives them, to smugglr exec --up|--down --version <v> --expect <fingerprint>. smugglr runs them on the place only when their hash is the one recorded for that version and the place has the expected fingerprint. The place must end with the local database's fingerprint, which the fingerprint note then records. A rebuild of a table that other tables reference reaches a D1 place with every row of the family. On success with autoclean on, the rewind-point snapshot, its ledger row and the working database's snapshot are removed and each is named in the output. On any failure, the local database is put back at the rewind point with both notes, nothing is removed, the command exits 1 with ship_failed, and the same command can be run again. A retry runs locally, before the sync, the migrations a failed run already took to the place, sends only the rest, and expects the place's fingerprint after the ones already taken. down --smuggl stops when the place holds migrations the rewind point does not, which can happen with autoclean off, because reverting from there would undo the wrong migration on the place. --discover (which requires --smuggl) prints smugglr's --discover --json report for the rewind point and the place, the migrations the run would send with their statements, and the tables, columns and row counts that each drop would destroy on the place. It changes nothing and exits 0 when the run could go ahead, or 3 when it would stop. A smugglr report that is not JSON is an error, not a run with unknown counts. Both commands work on a place with a full-text table. Their syncs ignore the place's virtual tables, as dev's do. up's rehearsal copy makes virtual tables before the other objects, so on a rewind point written by VACUUM INTO, which lists a full-text table's shadow tables first, each migration's hashes are known and the check that the statements sent are the ones plan gives can pass.
  • The ledger records each migration's up and down hash (PR #84, #62; PR #99, #86; PR #101, #100): up now rehearses the pending migrations on an in-memory copy of the database's schema, the same way migratr plan works out statements. For each migration it runs the up, then the down that reverts it, and stores the SHA-256 of each statement list, joined with newlines, in the ledger row's up_hash and down_hash. The copy makes virtual tables first, so a full-text table's shadow tables are already made when its CREATE VIRTUAL TABLE runs. The ledger's own statements are left out of both hashes. A hash is NULL when it cannot be known: for an irreversible down, for every migration from one whose up fails on the copy onward, for a row record_applied writes, and in builds without the rusqlite feature. read_ledger_through reads hashes when the ledger has the columns and reads an older ledger without them. The library also exports Note (RewindPoint at version 0, Fingerprint at version 1), record_note, which writes or replaces a note in one atomic run and creates the ledger when it is absent, snapshot_for_dev(db_path, source, kind) with DevSnapshot, which snapshots the database at source among the snapshots of the one at db_path, has_keyword, which says whether a statement holds a keyword as a bare word rather than inside a quoted identifier, and RusqliteExecutor::shape_differences, the structural comparison dev uses.
  • migratr.jsonc settings (PR #83, #77): before any command runs, migratr reads the nearest migratr.jsonc in the working directory or a parent, or the file --config names. The file is JSON that may contain // and /* */ comments. It holds smuggl (the place: a file path, an https:// address or d1://<name>, unset by default), loud, safe and autoclean, all three true by default. A key that is not one of these four, or a value of the wrong type, is a usage error that exits 2 and changes nothing. autoclean controls whether a successful ship removes its rewind point and working snapshot. safe is read and checked, but no command acts on it yet.

Fixed

  • The release scripts make their temp directories inside TMPDIR (PR #76, #75): scripts/release.sh, scripts/test-release.sh and scripts/test-install.sh called a bare mktemp -d, which on macOS ignores TMPDIR. The release scripts' perimeter guard checks paths against TMPDIR, so wherever TMPDIR was not the system default, test-release.sh failed two of its cases and release.sh stopped at preflight. They now call mktemp -d "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX", as legion's copies of the scripts already do.
  • rusqlite 0.41 for RUSTSEC-2026-0459 (PR #98, #97): bundled SQLite before 3.54.0 can return uninitialized page-cache memory when it reads a crafted -wal file. The workspace now uses rusqlite 0.41 (libsqlite3-sys 0.39), which bundles the fixed SQLite. That release needs Rust 1.89, so the workspace and every crate now declare rust-version = "1.89", and an older toolchain refuses to build migratr.

Changed

  • Commands are loud by default (PR #83, #77): with loud on, which is the default, every command writes to stderr the settings file used (or that none was found), each key with its value and whether the file or the default set it, and, for up and down, each migration as it starts and each statement it runs. Each run ends with the note loud can be turned off in migratr.jsonc: "loud": false. Stdout, including --json documents, is unchanged. A script that treats any stderr output as failure should set "loud": false. Because the nearest migratr.jsonc above the working directory is read on every command, a malformed one, or one with an unknown key, now fails every command with exit 2.
  • status lists the ledger's notes, and the CLI has new error codes (PR #85, #78; PR #88, #79; PR #93, #82; PR #99, #86): status prints each note as its kind followed by its JSON (rewind_point {...}, fingerprint {...}), and its --json document gains a notes array of {kind, value}. Notes are never reported as missing files. New --json error codes are smugglr_missing, not_adoptable, autoincrement, shape_changed, no_rewind_point, ship_failed, smugglr (smugglr refused or failed, in its own words) and io. up and down now list their exit codes in --help: 0 done, 1 failed, 2 usage, 3 a --discover that would stop.

0.2.0

Minor release: the public types of the migratr and migratr-format libraries change in ways that break code built against 0.1. Op is now #[non_exhaustive] and has four new variants; Op::CreateTable gains checks and unique, and Op::CreateIndex gains where_clause; IndexDef.columns and Op::CreateIndex.columns change from Vec<String> to Vec<IndexColumn>; and MigrateError, which is not non-exhaustive, gains NoSuchForeignKey and TriggerMismatch. A 0.1.5 would be picked up by every ^0.1 dependent and fail its build, as smugglr's did. The migration file format only gains fields and operations, every existing file keeps its checksum, and the ledger's schema is unchanged, with no schema migration.

The relationships release. A migration can now add a foreign key to a table that already exists, drop one, give a table CHECK and composite UNIQUE constraints, and create or drop a trigger, all as typed operations rather than raw_sql. Indexes can be partial, built on an expression, descending, or collated. The table rebuild these operations depend on no longer turns foreign keys off or creates TEMP objects, which D1 refuses, so the same rebuild now runs on a local file and on a D1 database. A table that other tables reference is rebuilt together with them.

New

  • add_foreign_key, drop_foreign_key, and partial, expression and descending indexes (PR #69, #66): {"op": "add_foreign_key", "table", "columns", "references": {"table", "columns"}, "on_delete", "on_update"} rebuilds its table with a table-level FOREIGN KEY item added and keeps every row and index; a key that references its own table works the same way. The rows already in the table are the check: before any change, up counts the rows whose key columns are all non-NULL and name no parent row, and refuses with ForeignKeyViolation naming the table and that count. plan now makes the same count, so it refuses with the same error as up would. drop_foreign_key carries the key's definition and removes either a table-level FOREIGN KEY item or the one column's inline REFERENCES clause. When the table has neither, it refuses with the new MigrateError::NoSuchForeignKey (--json code no_such_foreign_key). Each of the two is the other's inverse, so down reverses both. create_index takes a where clause for a partial index, and each entry in columns is either a bare column name or an object with exactly one of name or expr, plus optional desc and collate, written as <key> COLLATE <name> DESC. A key that is only a name parses as IndexColumn::Name whether it is written as "a", {"name": "a"} or {"name": "a", "desc": false}, so all three spellings give the same checksum (PR #72, #71). Reversing a create_index, or a drop_index of a partial index, keeps its WHERE clause. The new Executor::missing_parents and Executor::foreign_key_violations are default methods that return None, so an existing Executor still compiles. RusqliteExecutor overrides both, and any other executor can do the same through the exported migratr::missing_parents_through and migratr::foreign_key_violations_through over a SqlReader.
  • Table CHECK and UNIQUE constraints, and create_trigger and drop_trigger (PR #70, #59; PR #72, #71): create_table takes checks and unique and writes them after the PRIMARY KEY item as CHECK (...) and then UNIQUE (...), in the order given. Each check is an expression kept verbatim, or {"name", "expr"}, which is written as CONSTRAINT "name" CHECK (expr); each unique entry is a list of columns. Both fields are omitted from the canonical JSON when empty, so files written before this release keep their checksums. The order of checks, of unique lists, and of the columns in each is part of the checksum, and the rustdoc says so. create_trigger holds a TriggerDef (name, table, sql) and runs sql verbatim, hashed exactly as written, whitespace included. drop_trigger carries the same definition, and each operation is the other's inverse. A create_trigger whose name or table differs from what its statement names is refused before anything runs, with the new MigrateError::TriggerMismatch (--json code trigger_mismatch) naming both. Before this check, such a trigger applied and its down then failed with "no such trigger". drop_trigger counts as destructive, as drop_index does, so it takes a snapshot first. migratr new drop_<name> now looks for a trigger in schema.json after tables and indexes, and copies the trigger's definition into the new file.

Changed

  • A rebuild uses no TEMP objects, leaves foreign keys on, and rebuilds a referenced table with the tables that reference it (PR #68, #67): up now always calls run_atomic with suspend_foreign_keys false, and no rebuild statement creates a TEMP table or trigger or sets foreign_keys. The family is the rebuilt table plus every table with a foreign key that references it. Each table in the family gets a new table whose references name the new parent (for a self-reference, its own new table). The rows are copied parents first, the old child tables are dropped before the old parent, and the new tables are renamed with the parent first, so SQLite rewrites the references to the final names and nothing is left under a temporary name. The foreign-key check used to run inside the transaction after the copy, over the whole database, through a TEMP table whose trigger raised an error. Now the rows a foreign key would refuse are counted before any change, only over the family's tables, through Executor::foreign_key_violations, and a non-zero count refuses with ForeignKeyViolation naming the table and the count. An executor that keeps the default None gets no count. Its copy then fails on such a row inside the atomic run, which returns MigrateError::Apply rather than ForeignKeyViolation, and nothing changes. A database whose foreign-key violations are only in tables the rebuild does not touch is no longer refused.

0.1.4

Patch release: one trait and two functions added to the existing migratr library API, with no change to the CLI, the migration file format, or the ledger's schema, and no schema migration.

The shared-reader release. A program that drives migrations over something other than a rusqlite connection can now read a database's schema and ledger through migratr itself, by supplying only a way to run a SQL statement and return its rows as JSON. Until now such a caller had to copy those reads, as smugglr's --migratr does for its Executor over HTTP-SQL. RusqliteExecutor now reads through the same code, so the queries and decoding exist once. It returns the same schema and ledger as before, though some of the errors it returns for a malformed row are different variants of rusqlite::Error.

New

  • One reader of the schema and ledger, for any way of running SQL (PR #56, #55): the new migratr::SqlReader trait has two methods: rows(sql) runs a statement and returns its rows as Vec<Vec<serde_json::Value>>, and malformed(what) builds the caller's error for a row that is not what its statement promises. migratr::read_schema_through(&mut reader, skip) returns the same SchemaSnapshot that Executor::read_schema returns, and migratr::read_ledger_through(&mut reader) returns the ledger rows ordered by version, or an empty list when _migratr_migrations does not exist. The skip predicate names tables the reader must not touch, such as a host's own: a skipped table is not queried, and every sqlite_master object on it, such as an index, is left out of the snapshot. A value of the wrong type, a row with too few columns, and a negative ledger version are all errors. A test in crates/migratr/tests/reader.rs reads one database through a JSON-row reader and through RusqliteExecutor and asserts that the schema and the ledger match. All three items build with default features off.

Changed

  • RusqliteExecutor reads through the shared reader, which changes some error variants (PR #56, #55): read_schema and read_ledger are now thin calls into read_schema_through and read_ledger_through, and return what they returned before for a well-formed database. A negative ledger version used to return rusqlite::Error::IntegralValueOutOfRange and now returns rusqlite::Error::InvalidColumnName carrying the text "a negative ledger version". A row of the wrong shape now returns that same variant with a description in place of rusqlite's own conversion error, and a blob where text is expected fails as "a value that is not text", because the reader sees a blob as null. Code that matches on those specific variants needs updating; the refusal itself is unchanged.

0.1.3

Patch release: two additive functions in the existing migratr library API, with no change to the behavior of up or down, the CLI, the migration file format, or the ledger's schema, and no schema migration.

The rebuild-and-record release. A program holding an Executor can now ask whether a migration would rebuild tables on a given database before running anything, and can mark a migration as applied on a database that already has its shape, without running it. Both exist for callers that drive migrations themselves, the first being smugglr's --migratr. Alongside them, the release procedure picks up two corrections from its first end-to-end run, and the workspace gains a runner for acceptance scenarios.

New

  • The library says which tables a migration rebuilds, and records a migration without running it (PR #52, #51): migratr::rebuild_tables(&schema, &migration) takes a schema read through Executor::read_schema and returns the tables up would rebuild, each named once in operation order, or an empty list when the migration needs no rebuild. It counts a dropped column only when the column needs the rebuild, discounts an index the migration dropped first, and refuses with UnparseableTable when a dropped column's table has a CREATE statement that does not split. The decision moved into one function that up now calls too, so the report cannot drift from what up does, and up's tests are unchanged. The report covers tables only: up still refuses a migration whose rebuild is not its first operation, even though rebuild_tables names that table. migratr::record_applied(&mut exec, &migration) writes the migration's ledger row, with the migration's checksum, through any Executor, creating _migratr_migrations when it is absent and running none of the migration's operations. The ledger and the row land in one atomic run, so a failure returns MigrateError::Apply and leaves no ledger, and a version the ledger already holds is refused the same way. A later up treats the recorded migration as applied and does not run it. Both functions build with default features off.
  • Acceptance scenarios run under cargo test (PR #43, #35): rstest, rstest-bdd, and rstest-bdd-macros are now workspace dev-dependencies, and crates/migratr-cli/tests/bdd.rs runs every .feature file under that crate's tests/, so scenarios run in the existing CI workflow with no new one. A scenario with no matching step code fails the test, and the failure names the scenario. One @smoke scenario proves the wiring against behavior migratr already documents: restore without --yes exits 1 with the error code restore_not_confirmed. CLAUDE.md says where scenarios live and that they are generated from the legion requirement, never hand-edited. Nothing published changes, since these are test-only dependencies.

Fixed

  • The release procedure's issues carry criteria, and its live-site wait follows the deploy (PR #42, #33): both faults were found by the 0.1.2 release, the first run of RELEASING.md end to end. Steps 3 and 9 created issues whose body was a bare sentence, and the pr-write gate needs an issue to map, so those bodies now put the criterion under an ## Acceptance criteria heading. Step 11 used to fetch the smugglr.dev pages up to 30 times, 60 seconds apart, until they showed the new version, but WebFetch caches a URL for 15 minutes. It now polls the Workers Builds: smugglr-shingle check on shingle's merged commit every 20 seconds for up to 30 minutes, and once that check reports success it fetches each page with ?r=X.Y.Z on the URL, which gets past the cache, and confirms the version.

0.1.2

Patch release: new installer and release tooling around the existing binary, with no change to any crate's code, the library API, the CLI, the migration file format, or the ledger.

The installer release. migratr now has a one-line install: curl -fsSL https://raw.githubusercontent.com/rafters-studio/migratr/main/install.sh | bash downloads the newest published binary for the machine, verifies it against the release's checksums, and puts it on the PATH, with no version written into the script, so each release updates the installer without anyone editing it. Alongside it, migratr is now released by one agent run with no operator step, following a written procedure that bumps the version, writes this changelog, merges the release PR, tags it, and publishes the changelog to smugglr.dev.

New

  • install.sh installs the latest migratr release (PR #34, #32): run as curl -fsSL <url> | bash, the installer at the repo root detects the platform (linux or macos) and architecture (x64 or arm64, preferring the native arm64 build when a macOS shell runs under Rosetta 2), resolves the version, downloads migratr-<os>-<arch>.tar.gz and checksums.txt from that GitHub release, and refuses to install unless the archive's SHA-256 matches its line in checksums.txt. The version comes from the first argument (bash -s v0.1.1), then MIGRATR_VERSION, then the tag the releases/latest redirect points at. It installs to MIGRATR_INSTALL_DIR (default ~/.local/bin) and, when that directory is not on the PATH, appends a PATH line to .bashrc, .zshrc, or fish's config.fish, only if it is not already there. It uses curl or falls back to wget. Platforms with no published build (Windows, linux-arm64) are refused before any download with a pointer to cargo install migratr-cli. The install ends by running migratr --version; a binary that fails to run is reported as an install error, not a success. scripts/test-install.sh runs the installer against real published releases, and CI runs it on Linux and macOS.
  • Releases run with no operator step (PR #36, PR #37, PR #38, #33): RELEASING.md is the procedure an agent follows to release migratr from a clean main to a live smugglr.dev page, stopping and reporting on the first failure. release.toml declares the version file (workspace.package.version in Cargo.toml), this changelog, the tag format v{version}, the preflight commands (fmt, clippy, tests, and the release-script tests), and the shingle docs branch. scripts/release.sh and scripts/sync-version.sh are copied from legion with two patches: the version bump also moves the version pin on every path = "..." dependency between the workspace crates, and --activate is refused. The bump level is read from the first line of the new changelog entry (for this entry, Patch release:). After release.yml publishes the GitHub release, polled with gh rather than curl so legion's network hook cannot stall the run, the procedure copies CHANGELOG.md into shingle and merges a docs PR so https://smugglr.dev/migratr/changelog/ shows the new entry. scripts/test-release.sh covers the scripts, skips its legion-backed cases when legion is not installed, and runs in CI.

0.1.1

The release-pipeline release. Pushing a v* tag now builds the migratr binary for four platforms, attaches them to a GitHub release with checksums, and publishes the four workspace crates to crates.io, so a release needs no manual step. Alongside it, the refusal for an edited applied migration now tells the user what to do instead of only what went wrong. Patch release: a message rewording within an existing error (the checksum_mismatch code is unchanged) and new release automation, no API change, no change to the migration file format or the ledger.

New

  • A pushed tag releases migratr (PR #29, #28): .github/workflows/release.yml runs on any v* tag. It builds migratr-cli in release mode for x86_64-unknown-linux-gnu, x86_64-apple-darwin, aarch64-apple-darwin, and x86_64-pc-windows-msvc, packages each as migratr-<os>-<arch>.tar.gz (or .zip on Windows), and creates a GitHub release carrying the archives, a checksums.txt of their SHA-256 sums, and generated release notes. A parallel job publishes to crates.io through trusted publishing (rust-lang/crates-io-auth-action, no stored token). Before publishing anything it refuses unless the tag equals v plus the version in [workspace.package] of Cargo.toml. It then publishes in dependency order (migratr-format, migratr-macros, migratr, migratr-cli), skipping any crate whose version is already in the crates.io index and treating cargo's "already exists" as success, so a run that failed partway can be re-run and publishes only what is missing.

Fixed

  • The checksum-mismatch refusal says how to recover (PR #27, #24): when an applied migration's file has been edited, up and down (and Migrator::status) refuse with MigrateError::ChecksumMismatch. The message used to say only that the checksum no longer matched the ledger. It now reads "migration <version>_<name> was edited after it was applied. Applied migrations are not edited: restore the file to what was applied, then write a new migration for the change". The same text reaches the CLI's --json error document under the unchanged checksum_mismatch code, and tests in both the library and the CLI pin it.

0.1.0

The first release. migratr manages SQLite schema migrations written as JSON files, applies them atomically against a ledger, rebuilds tables safely where SQLite cannot alter in place, reverses only what has an exact inverse, and snapshots the database before any destructive step. It ships as a library (migratr, with an embed! macro and Migrator for migrations compiled into a program) and as a CLI (migratr) with machine-readable --json output.

New

  • Migrations as JSON files (PR #12, #2): each migration is a JSON file of typed operations named by version and name. The parser reports the exact JSON path of a bad field, lists every file that shares a version, and computes a checksum per file so an edit after apply is detected.
  • Ledger and up (PR #13, #3): applied migrations are recorded in a ledger table. up applies each pending migration and its ledger row in one atomic run; a failure rolls it back and names the failing statement and operation. up refuses to run when an applied file was edited or a ledger row has no file.
  • Safe table rebuilds (PR #14, #4): an operation SQLite cannot do in place, such as dropping a column it refuses to drop, rebuilds the table by SQLite's 12-step procedure, editing the stored CREATE TABLE text with a comment- and quote-aware scanner. Indexes, triggers, and dependent views are recreated after the row copy, rowids and sqlite_sequence carry over, and foreign_key_check runs before commit. A rebuild is refused before anything runs when the table's CREATE TABLE does not parse, when another object uses the dropped column or the table's columns by position, or when the rebuild is not the first operation in its migration. The rebuild is checked against a hazard oracle covering nine SQLite rebuild hazards (PR #16, #5).
  • down reverses only exact inverses (PR #15, #6): down reverses the newest N applied migrations, newest first, each with its ledger delete in one atomic run. Following the Rails rule, an operation with no exact inverse makes the whole range refuse with irreversible before anything runs. down reverses structure only, and says that data in dropped objects is not restored.
  • Snapshots and restore (PR #17, #7): before a destructive step in up or down, migratr copies the database into .migratr/snapshots/ next to it and keeps the newest snapshot; a snapshot that cannot be written stops the step. restore replaces the database with the latest snapshot, or a named one, and changes nothing without --yes.
  • schema.json and new (PR #18, #8): after every successful up and down, migratr writes schema.json in the migrations directory describing the resulting schema. new scaffolds a migration file from a Rails-style name and column specs (such as create_users id:integer:pk), checked against schema.json.
  • embed! and Migrator (PR #21, #10): migratr::embed!("migrations") embeds a migrations directory in the program and parses it at compile time with the library's own parser, so a malformed file stops the build. Migrator offers up, down, status, and plan over the embedded set.
  • The CLI, with --json (PR #20, #9): migratr [--db PATH] [--dir PATH] [--json] <new|up|down|status|plan|restore>. plan prints the statements a run would execute, which steps are destructive, and the snapshot each would take, changing nothing. With --json, each command writes one JSON document to stdout carrying command and status; a failure adds a stable error code and message and exits non-zero (2 for usage errors, 1 otherwise).
  • Published to crates.io (PR #26, #25): the workspace publishes as migratr-format, migratr-macros, migratr, and migratr-cli under the MIT license, with CI verifying each crate builds from its own package.