This seems pretty straight forward, but I'm not sure what is going wrong.
I am trying to do the following in my Rails migration:
change_column :foo, :bar, :text, :limit => 16777215
I get the following error
Mysql::Error: BLOB/TEXT column 'bar' can't have a default value: ALTER TABLE `foo` CHANGE `bar` `email_contents` text(16777215) DEFAULT '' NOT NULL
The only thing I can understand is the problem is that this change_column happens shortly after I added the column to foo and had to change it from type: string to enter text: in the first place. Each of them comes from its own migration scenarios and looks like this:
add_column :foo, :bar, :string, :null => false
and
change_column :foo, :bar, :text
As an experiment, I tried to change the first change_column (change_column: foo ,: bar ,: text) and found that this successfully modifies the table. Unfortunately, I cannot change any of the previous migrations and add only new ones to our current implementation so that they do not work in production. The question is, what allows me to change a column once, but not twice?
Update . I tried the first sentence, but got the following:
Mysql::Error: BLOB/TEXT column 'bar' can't have a default value: ALTER TABLE `foo` CHANGE `bar` `bar` text(16777215) DEFAULT ''