Abstract
A method is disclosed for preventing a schema-migration runner from committing a migration it has not recorded in its applied-migration ledger. Before applying a non-empty set of pending migrations, the runner executes the exact statement it will later use to record each migration, an insert-or-update keyed on a unique index over the ledger's version column, with a reserved sentinel version outside every migration filename grammar, inside a transaction that is rolled back whether the write succeeded or failed. Any error, such as a missing unique index on a legacy-shaped ledger or a ledger owned by another role, ends the run before any migration statement executes and returns a not-ok result naming the ledger and, when the transaction or write failed, the likely remediation. Each migration then executes its statements, its recording write and a read-back of its own ledger row inside one transaction, and the runner refuses to commit, rolling the migration back, when the read-back finds no row. A strict mode stops the run at the first failed migration and turns a returned not-ok result into a terminal failure: at service start the process exits with a failure status, and a pre-deployment check spawns the runner in strict mode against the target database, blocking deployment on a non-zero exit, a spawn error, a timeout or a failure to run the check. Without strict mode, per-migration failures are logged and the run continues past them, and the start sequence publishes an informational drift snapshot of a returned result.
Creative Commons License

This work is licensed under a Creative Commons Attribution 4.0 License.
Recommended Citation
Assuncao, gustavo matthew, "Recorder-Proof Migration Runner: Rolled-Back Sentinel Preflight of the Exact Ledger Write and In-Transaction Ledger-Row Readback Before Commit, with Strict-Mode Start and Deploy Enforcement", Technical Disclosure Commons, ()
https://www.tdcommons.org/dpubs_series/13246