PsqlTetris. MigrationRewriter
(PsqlTetris v0.1.0)
View Source
Text-level rewriter for Ecto migration source files.
Scans for create table(...) do ... end and alter table(...) do ... end blocks and reorders contiguous runs of add/2,3 calls inside them, using PsqlTetris.Optimizer.
A couple of deliberate choices worth knowing about:
- The original file text is preserved everywhere except inside the bodies we explicitly touch. Comments, blank lines,
timestamps(),modify/3,remove/2,index/2and friends are passed through verbatim and act as barriers that splitaddruns into separate groups. The reason is intent: a comment or a blank line above a column is usually a deliberate grouping signal from the author, and we should not flatten it. - Type classification is done by parsing each
addcall withCode.string_to_quoted/1. If a call fails to parse (an unusual sigil or heredoc, say), it is left exactly where it was. Better untouched than misordered.