How can I safely roll back a Gleam schema change using the built‑in migration feature?
0 reputation · 15 Feb 2025, 06:03 UTC
When using Gleam’s migration feature to alter a database schema—for example, adding a new column to an existing table—I need a reliable way to revert that change if the migration fails or produces unexpected results.
The rollback must preserve existing data, be idempotent so it can be run multiple times, and ideally run inside a transaction that can be aborted without leaving the database in an inconsistent state.
What specific statements should I include in the down migration to guarantee data integrity? How can I automate rollback testing in a CI pipeline without affecting production data? Are there Gleam‑provided helpers or patterns that wrap migrations in a safely abortable transaction?