dbsrgits / sql-translator

SQL::Translator (SQLFairy)
http://sqlfairy.sourceforge.net/
82 stars 91 forks source link

Support new column info 'initially_populated_from' and populate new columns when added #94

Open dboehmer opened 7 years ago

dboehmer commented 7 years ago

I use DBIC DeploymentHandler to generate DDL files for upgrading my database during schema changes. The generated SQL is valid but could be improved. Currently I use SQLite for development but it might apply to other DBMS as well.

My issue:

My reasoning:

Before I really understood the issue I talked through this on IRC with ribasushi and he came up with this solution:

so I think what you actually want is an {extra} field of 'initially_populated_from_column' which is handled just like 'renamed_from' for columns themselves https://metacpan.org/source/ILMARI/SQL-Translator-0.11021/lib/SQL/Translator/Diff.pm#L390 then the boilerplate can literally generate what you want without any hand editing and remains usable outside of your particular case as well ( it is a useful feature in general ) probably just 'initially_populated_from' - takes both a scalar ( a column name ) and a scalarref ( a literal default )