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 devcopies the place and records a rewind point (PR #85, #78; PR #88, #79; PR #95, #94; PR #99, #86; PR #101, #100):devreads the place withsmugglr exec <place> --read. It then builds a new database in.migratr/devbeside the local one, in this order: the place's tables, its rows throughsmugglr 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, andsmugglr sync --dryrunmust 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.dbsnapshot, its stale-waland-shmfiles removed, and the new one renamed into place.devtakes its snapshots withVACUUM INTO, not a file copy, so writes still in a WAL are kept. Pruning never removeskeptordevsnapshots. They do count towardlatest_snapshot, so afterdevthe latest snapshot thatstatusshows andrestorepicks by default is the rewind point, which sorts after any other snapshot of the same second. The firstdevagainst 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,devrecords every migration. Otherwise it stops withnot_adoptable, naming each difference by table. A laterdevcompares the place's fingerprint with the recorded one. If they differ, it stops withshape_changedand 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 --discoverprintssmugglr sync --discoverfor the local database and the place.devneeds smugglr 0.6.3 or later, the first release withexec, found throughSMUGGLRor elsesmugglron the PATH. Without it,devrefuses withsmugglr_missingand names the version to install. CI now installs smugglr v0.6.3 for the tests. A place with an AUTOINCREMENT table is refused withautoincrement, 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 withCREATE VIRTUAL TABLE, replay first, so each makes its own shadow tables, and the replay skips any object already made. A place written byVACUUM INTOlists 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, sodevadds 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 generatedVIRTUALcolumn is an ordinary table and syncs its rows. A faileddevleaves 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/paircome after it, and a failure from there puts the old local database back from itskeptsnapshot (or removes the new one when there was none) and puts back the old pair's memory, whichdevsets 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 --smugglanddown --smugglship through the rewind point (PR #90, #81; PR #92, #91; PR #93, #82; PR #99, #86; PR #101, #100):up --smuggl(honouring--to) anddown --smuggl(honouring--steps) first check three things: that the rewind point's file still has the SHA-256devrecorded, that the ledger holds a rewind point at all (otherwiseno_rewind_point, telling you to runmigratr dev), and that the place's fingerprint is the recorded one (otherwiseshape_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 memorydevleft in.migratr/pair, so the place's inserts, updates and deletes sincedevarrive 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, asmigratr plangives them, tosmugglr 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 withautocleanon, 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 withship_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 --smugglstops when the place holds migrations the rewind point does not, which can happen withautocleanoff, because reverting from there would undo the wrong migration on the place.--discover(which requires--smuggl) prints smugglr's--discover --jsonreport 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, asdev's do.up's rehearsal copy makes virtual tables before the other objects, so on a rewind point written byVACUUM 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 onesplangives can pass.- The ledger records each migration's up and down hash (PR #84, #62; PR #99, #86; PR #101, #100):
upnow rehearses the pending migrations on an in-memory copy of the database's schema, the same waymigratr planworks 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'sup_hashanddown_hash. The copy makes virtual tables first, so a full-text table's shadow tables are already made when itsCREATE VIRTUAL TABLEruns. 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 rowrecord_appliedwrites, and in builds without therusqlitefeature.read_ledger_throughreads hashes when the ledger has the columns and reads an older ledger without them. The library also exportsNote(RewindPointat version 0,Fingerprintat 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)withDevSnapshot, which snapshots the database atsourceamong the snapshots of the one atdb_path,has_keyword, which says whether a statement holds a keyword as a bare word rather than inside a quoted identifier, andRusqliteExecutor::shape_differences, the structural comparisondevuses. migratr.jsoncsettings (PR #83, #77): before any command runs, migratr reads the nearestmigratr.jsoncin the working directory or a parent, or the file--confignames. The file is JSON that may contain//and/* */comments. It holdssmuggl(the place: a file path, anhttps://address ord1://<name>, unset by default),loud,safeandautoclean, all threetrueby 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.autocleancontrols whether a successful ship removes its rewind point and working snapshot.safeis 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.shandscripts/test-install.shcalled a baremktemp -d, which on macOS ignoresTMPDIR. The release scripts' perimeter guard checks paths againstTMPDIR, so whereverTMPDIRwas not the system default,test-release.shfailed two of its cases andrelease.shstopped at preflight. They now callmktemp -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
-walfile. 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 declarerust-version = "1.89", and an older toolchain refuses to build migratr.
Changed
- Commands are loud by default (PR #83, #77): with
loudon, 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, forupanddown, each migration as it starts and each statement it runs. Each run ends with the noteloud can be turned off in migratr.jsonc: "loud": false. Stdout, including--jsondocuments, is unchanged. A script that treats any stderr output as failure should set"loud": false. Because the nearestmigratr.jsoncabove the working directory is read on every command, a malformed one, or one with an unknown key, now fails every command with exit 2. statuslists the ledger's notes, and the CLI has new error codes (PR #85, #78; PR #88, #79; PR #93, #82; PR #99, #86):statusprints each note as its kind followed by its JSON (rewind_point {...},fingerprint {...}), and its--jsondocument gains anotesarray of{kind, value}. Notes are never reported as missing files. New--jsonerror codes aresmugglr_missing,not_adoptable,autoincrement,shape_changed,no_rewind_point,ship_failed,smugglr(smugglr refused or failed, in its own words) andio.upanddownnow list their exit codes in--help: 0 done, 1 failed, 2 usage, 3 a--discoverthat 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-levelFOREIGN KEYitem 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,upcounts the rows whose key columns are all non-NULL and name no parent row, and refuses withForeignKeyViolationnaming the table and that count.plannow makes the same count, so it refuses with the same error asupwould.drop_foreign_keycarries the key's definition and removes either a table-levelFOREIGN KEYitem or the one column's inlineREFERENCESclause. When the table has neither, it refuses with the newMigrateError::NoSuchForeignKey(--jsoncodeno_such_foreign_key). Each of the two is the other's inverse, sodownreverses both.create_indextakes awhereclause for a partial index, and each entry incolumnsis either a bare column name or an object with exactly one ofnameorexpr, plus optionaldescandcollate, written as<key> COLLATE <name> DESC. A key that is only a name parses asIndexColumn::Namewhether it is written as"a",{"name": "a"}or{"name": "a", "desc": false}, so all three spellings give the same checksum (PR #72, #71). Reversing acreate_index, or adrop_indexof a partial index, keeps itsWHEREclause. The newExecutor::missing_parentsandExecutor::foreign_key_violationsare default methods that returnNone, so an existingExecutorstill compiles.RusqliteExecutoroverrides both, and any other executor can do the same through the exportedmigratr::missing_parents_throughandmigratr::foreign_key_violations_throughover aSqlReader.- Table CHECK and UNIQUE constraints, and
create_triggeranddrop_trigger(PR #70, #59; PR #72, #71):create_tabletakeschecksanduniqueand writes them after thePRIMARY KEYitem asCHECK (...)and thenUNIQUE (...), in the order given. Each check is an expression kept verbatim, or{"name", "expr"}, which is written asCONSTRAINT "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_triggerholds aTriggerDef(name,table,sql) and runssqlverbatim, hashed exactly as written, whitespace included.drop_triggercarries the same definition, and each operation is the other's inverse. Acreate_triggerwhosenameortablediffers from what its statement names is refused before anything runs, with the newMigrateError::TriggerMismatch(--jsoncodetrigger_mismatch) naming both. Before this check, such a trigger applied and itsdownthen failed with "no such trigger".drop_triggercounts as destructive, asdrop_indexdoes, so it takes a snapshot first.migratr new drop_<name>now looks for a trigger inschema.jsonafter 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):
upnow always callsrun_atomicwithsuspend_foreign_keysfalse, and no rebuild statement creates a TEMP table or trigger or setsforeign_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, throughExecutor::foreign_key_violations, and a non-zero count refuses withForeignKeyViolationnaming the table and the count. An executor that keeps the defaultNonegets no count. Its copy then fails on such a row inside the atomic run, which returnsMigrateError::Applyrather thanForeignKeyViolation, 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::SqlReadertrait has two methods:rows(sql)runs a statement and returns its rows asVec<Vec<serde_json::Value>>, andmalformed(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 sameSchemaSnapshotthatExecutor::read_schemareturns, andmigratr::read_ledger_through(&mut reader)returns the ledger rows ordered by version, or an empty list when_migratr_migrationsdoes not exist. Theskippredicate names tables the reader must not touch, such as a host's own: a skipped table is not queried, and everysqlite_masterobject 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 incrates/migratr/tests/reader.rsreads one database through a JSON-row reader and throughRusqliteExecutorand asserts that the schema and the ledger match. All three items build with default features off.
Changed
RusqliteExecutorreads through the shared reader, which changes some error variants (PR #56, #55):read_schemaandread_ledgerare now thin calls intoread_schema_throughandread_ledger_through, and return what they returned before for a well-formed database. A negative ledger version used to returnrusqlite::Error::IntegralValueOutOfRangeand now returnsrusqlite::Error::InvalidColumnNamecarrying 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 throughExecutor::read_schemaand returns the tablesupwould 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 withUnparseableTablewhen a dropped column's table has aCREATEstatement that does not split. The decision moved into one function thatupnow calls too, so the report cannot drift from whatupdoes, andup's tests are unchanged. The report covers tables only:upstill refuses a migration whose rebuild is not its first operation, even thoughrebuild_tablesnames that table.migratr::record_applied(&mut exec, &migration)writes the migration's ledger row, with the migration's checksum, through anyExecutor, creating_migratr_migrationswhen it is absent and running none of the migration's operations. The ledger and the row land in one atomic run, so a failure returnsMigrateError::Applyand leaves no ledger, and a version the ledger already holds is refused the same way. A lateruptreats 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, andrstest-bdd-macrosare now workspace dev-dependencies, andcrates/migratr-cli/tests/bdd.rsruns every.featurefile under that crate'stests/, 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@smokescenario proves the wiring against behavior migratr already documents:restorewithout--yesexits 1 with the error coderestore_not_confirmed.CLAUDE.mdsays 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.mdend 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 criteriaheading. 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 theWorkers Builds: smugglr-shinglecheck on shingle's merged commit every 20 seconds for up to 30 minutes, and once that check reportssuccessit fetches each page with?r=X.Y.Zon 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.shinstalls the latest migratr release (PR #34, #32): run ascurl -fsSL <url> | bash, the installer at the repo root detects the platform (linuxormacos) and architecture (x64orarm64, preferring the native arm64 build when a macOS shell runs under Rosetta 2), resolves the version, downloadsmigratr-<os>-<arch>.tar.gzandchecksums.txtfrom that GitHub release, and refuses to install unless the archive's SHA-256 matches its line inchecksums.txt. The version comes from the first argument (bash -s v0.1.1), thenMIGRATR_VERSION, then the tag thereleases/latestredirect points at. It installs toMIGRATR_INSTALL_DIR(default~/.local/bin) and, when that directory is not on the PATH, appends a PATH line to.bashrc,.zshrc, or fish'sconfig.fish, only if it is not already there. It usescurlor falls back towget. Platforms with no published build (Windows, linux-arm64) are refused before any download with a pointer tocargo install migratr-cli. The install ends by runningmigratr --version; a binary that fails to run is reported as an install error, not a success.scripts/test-install.shruns 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.mdis the procedure an agent follows to release migratr from a cleanmainto a live smugglr.dev page, stopping and reporting on the first failure.release.tomldeclares the version file (workspace.package.versioninCargo.toml), this changelog, the tag formatv{version}, the preflight commands (fmt, clippy, tests, and the release-script tests), and the shingle docs branch.scripts/release.shandscripts/sync-version.share copied from legion with two patches: the version bump also moves theversionpin on everypath = "..."dependency between the workspace crates, and--activateis refused. The bump level is read from the first line of the new changelog entry (for this entry,Patch release:). Afterrelease.ymlpublishes the GitHub release, polled withghrather thancurlso legion's network hook cannot stall the run, the procedure copiesCHANGELOG.mdinto shingle and merges a docs PR so https://smugglr.dev/migratr/changelog/ shows the new entry.scripts/test-release.shcovers 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.ymlruns on anyv*tag. It buildsmigratr-cliin release mode forx86_64-unknown-linux-gnu,x86_64-apple-darwin,aarch64-apple-darwin, andx86_64-pc-windows-msvc, packages each asmigratr-<os>-<arch>.tar.gz(or.zipon Windows), and creates a GitHub release carrying the archives, achecksums.txtof 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 equalsvplus theversionin[workspace.package]ofCargo.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,
upanddown(andMigrator::status) refuse withMigrateError::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--jsonerror document under the unchangedchecksum_mismatchcode, 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.upapplies each pending migration and its ledger row in one atomic run; a failure rolls it back and names the failing statement and operation.uprefuses 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 TABLEtext with a comment- and quote-aware scanner. Indexes, triggers, and dependent views are recreated after the row copy, rowids andsqlite_sequencecarry over, andforeign_key_checkruns before commit. A rebuild is refused before anything runs when the table'sCREATE TABLEdoes 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). downreverses only exact inverses (PR #15, #6):downreverses 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 withirreversiblebefore anything runs.downreverses structure only, and says that data in dropped objects is not restored.- Snapshots and restore (PR #17, #7): before a destructive step in
upordown, migratr copies the database into.migratr/snapshots/next to it and keeps the newest snapshot; a snapshot that cannot be written stops the step.restorereplaces the database with the latest snapshot, or a named one, and changes nothing without--yes. schema.jsonandnew(PR #18, #8): after every successfulupanddown, migratr writesschema.jsonin the migrations directory describing the resulting schema.newscaffolds a migration file from a Rails-style name and column specs (such ascreate_users id:integer:pk), checked againstschema.json.embed!andMigrator(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.Migratoroffersup,down,status, andplanover the embedded set.- The CLI, with
--json(PR #20, #9):migratr [--db PATH] [--dir PATH] [--json] <new|up|down|status|plan|restore>.planprints 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 carryingcommandandstatus; a failure adds a stable errorcodeandmessageand 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, andmigratr-cliunder the MIT license, with CI verifying each crate builds from its own package.