docs: explain which SQLMesh version to use with rollback - #6090
Conversation
The rollback docs did not say what to do about the installed version. Rollback restores the state tables from the backups taken by migrate, but leaves the installed package alone, so the newer version refuses to run against the restored state until it is migrated again. Add a rollback section to the migrations guide covering the order of steps, that only the latest migration can be rolled back, and that metadata changes made after the migration are discarded. Link to it from the CLI reference. Closes SQLMesh#4285 Signed-off-by: Adegbite Ayoade <[email protected]>
SQLMesh#6088 makes rollback report the versions it moved between, so the note would go stale as soon as that merges. Signed-off-by: Adegbite Ayoade <[email protected]>
Signed-off-by: Adegbite Ayoade <[email protected]>
mday-io
left a comment
There was a problem hiding this comment.
Thanks! Especially for verifying the behavior against two real releases. The steps and the "latest migration only" behavior match MigratorMixin.rollback.
Please address these two inline comments before merge:
- Scope the opening sentence to migrations that actually take a backup. The backup is conditional and can be disabled with
--skip-backup. - Add a bullet stating that rollback is unavailable or misleading when no backup was taken.
Both are small doc-only edits, and I've included ready-to-apply suggestions. Once they're in, this is good to go.
Co-authored-by: Michael Day <[email protected]> Signed-off-by: Adegbite Ayoade <[email protected]>
Co-authored-by: Michael Day <[email protected]> Signed-off-by: Adegbite Ayoade <[email protected]>
Signed-off-by: Adegbite Ayoade <[email protected]>
|
@tripleaceme looks like the DCO checks failed |
2bc1bc5 to
b0435f9
Compare
|
Thanks @mday-io — both suggestions are in, and the DCO failure is fixed in b0435f9. The two doc edits were applied as you wrote them: the opening sentence is now scoped to migrations that actually change something and mentions On the DCO failure — worth recording the cause, because it will otherwise keep happening. Four commits on this branch were made through the GitHub web UI: the two "Update docs/guides/migrations.md" commits from applying suggestions in the browser, and two "Update branch" merges. The web UI authors them as "Adegbite Ayoade Abel" (my GitHub display name, not my git config name) with Which is also why I applied your suggestions locally rather than using the "Apply suggestion" button — that button commits through the same path and would have re-broken the check immediately. All six commits now carry |
Description
Closes #4285.
The docs for
sqlmesh rollbackdid not say what to do about the installed SQLMesh version. Rollback restores the state tables from the_backuptables thatmigratecreates, but it does not touch the installed package, so the newer version refuses to run against the restored state until it is migrated again.Changes:
docs/guides/migrations.md: add a "Rolling back a migration" section. It covers how the backups work, the order of steps (roll back with the version that ran the migration, then reinstall the previous version), and three things to know before rolling back:migrate, it affects all users of the projectdocs/reference/cli.md: add one line underrollbacklinking to the new section.The guide recommends one order to keep things simple.
Context.rollbackcalls_new_state_sync()directly and skips the version check, so in practice the command also works after downgrading first.Test Plan
Docs only. I tested the behaviour described with two PyPI releases, 0.230.0 and 0.236.2 (the upgrade applies migrations v0101 and v0102), on a
sqlmesh init duckdbproject planned with 0.230.0:planwith 0.230.0: works, no changesrollbackwith 0.230.0: worksplanwith 0.236.2:SQLMesh (local) is using version '0.236.2' which is ahead of '0.230.0' (remote). Please run a migrationrollback:There are no prior migrations to roll back to.plan devwith 0.236.2, rollback:_environmentsgoes fromprod, devback toprodChecklist
make styleand fixed any issuesmake fast-test) (not run, no code changes)git commit -s) per the DCO