Shopify/lhm

NULL is improperly quoted when renaming a column

ttrmw opened this issue · 2 comments

ttrmw commented

when reading column definitions in lib/lhmmigrator.rb:84, the :column_default value is "NULL" for a column with a default value of NULL. This then gets quoted to "'NULL'", which does not work.

The mysql connection's quote method expects nil for NULL, but the guard clause in rename_column depends on the truthiness of :column_default. I guess a wider refactor could be made to separate out column_default from the actual default value, or perhaps a quote method on the migrator could account for "NULL" given as a string.

I'd be happy to work on a PR if you guys accept non-shopify contributors?

Definitely happy to accept a contribution, if you don't mind making a PR!