Is there a Ruby on Rails generate migration statement to change "description" from string to text?
It looks like string
is limited to 256 characters and text
is usually 65536 characters.
I tried
ruby script/generate migration change_description_to_text description:text
but the up
and down
in the migration file generated are both empty? Is there a way to generate this migration automatically?
If added manuall开发者_开发百科y using a remove_column
and an add_column
, will all the old data be removed for the column?
see the way of using migration itself wrong,
because you are changing the description string into text but u didnt specify which table so
use as following method.
ruby script/generate migration change_description_string_to_text
in migration,
def self.up
change_column :user, :description, :text
end
def self.down
change_column :user, :description, :string
end
精彩评论