开发者

Is there a Ruby on Rails generate migration statement to change "description" from string to text?

开发者 https://www.devze.com 2023-01-12 23:03 出处:网络
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

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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号