I have a column named ‘parent_id’ that I am trying to add a default of -1 to:
change_column :categories, :parent_id, :default => -1
The type is a integer in mysql.
I am getting the error:
'mysql2 error......'default-1 default null' at line 1:
alter table 'categories' change 'parent_id' 'parent_id' default-1 default null
It seems it is missing = sign?
Also, how do I do a db:migrate on the test db?
You’re missing the column type in your
change_column, it should be more like this:The giveaway is this:
default-1. Thechange_columnmethod wants three arguments and then a hash of optional arguments. Your:default => -1is getting mashed together as the column type because you didn’t specify:integeras the third argument.