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

timpone
  • 19,235
  • 36
  • 121
  • 211

2 Answers2

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.

Nick Colgan
  • 5,488
  • 25
  • 36
  • thx, didn't know that - is it normally achieved by just setting a default_values on the object in question – timpone May 25 '12 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

Community
  • 1
  • 1
Sergey Kishenin
  • 5,099
  • 3
  • 30
  • 50