Ecto migration rollbacks: Is automatic safe rollback for schema changes supported?
0 reputation · 16 Jan 2021, 21:40 UTC
Goal
Ensure that rolling back a schema migration does not inadvertently lose or corrupt data.
Current Constraints
Ecto requires a down function for every migration; if omitted the migration is deemed irreversible. The alter table DSL does not automatically generate reverse operations for added columns or renamed fields, and the :force option can silently truncate data during type changes.
Unresolved Decision
Whether Ecto should provide an automatic, safe rollback mechanism for column renames and type conversions remains undecided in the community. Current practice demands explicit handling, and there is no built‑in safeguard against accidental data loss.
Questions
Which Ecto migration constructs currently lack auto‑generated safe rollbacks that could protect data?
Can the :force option be used without risking silent truncation, or should it be avoided in production migrations?