The Rails guides to active record migrations says that you can do
change_column_default :products, :approved, from: true, to: false
I\'ve got a
When you try to downgrade the data type , from value
(0) to nil
in this case , rails will complain this error. Because it might lose data
Another example would be going from string
-> integer
.
this is a really good article explain the same
It seems like your reverse migration calls change_column_default
in command_recorder
(activerecord-4.2.0/lib/active_record/migration/command_recorder.rb#76)
please check if you set the nil
as the default value.
it turns out that, if you use change
in migrations, those have to be able to reversible
but change_column is not reversible through change
method. So you will have to use the old rails migration method with up
and down
read this article explain the scenario