开发者

In a migration, how do you change the column type to text without specifying the :limit?

开发者 https://www.devze.com 2023-03-20 12:01 出处:网络
I want to change a column type from :string to :text The problem is that if I simply do: change_column :questions, :content, :text

I want to change a column type from :string to :text

The problem is that if I simply do:

change_column :questions, :content, :text

Then the schema is rewritten to:

t.string   "content",     :limit => 255

i.e. it takes the length that was implicit whe开发者_JAVA百科n it was a string

How can I do the migration and specify that the :limit should not be set such that the schema reads:

t.string   "content"

I have tried setting an arbitrary limit of 10,000 but a) that feels inefficient and b) it makes the down migration attempt to set the :text limit to 10,000.

What option can I pass to the change_column method to ensure it simply uses the default limit?


Ack, discovered this by trial and error moments after posting the question:

change_column :questions, :content, :text, :limit => nil
0

精彩评论

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