0

I am trying to write a migration to handle the null -> '' conversion but it doesn't seem to be working. I have:

def up
  change_column :items, :detail, :text, :default => ''
end

Is this correct syntax?

thx

2 Answers 2

3

That looks about right.

You should be aware, however, if you're using MySQL you can not set a default value to a TEXT or BLOB field.

1
  • thx, didn't know that - is it normally achieved by just setting a default_values on the object in question
    – timpone
    May 25, 2012 at 16:37
0

Use should use change_column_default(table_name, column_name, dafault_value) This question has been already asked here: Rails migrations: Undo default setting for a column

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.