【问题标题】:In a migration, how do you change the column type to text without specifying the :limit?在迁移中,如何在不指定 :limit 的情况下将列类型更改为文本?
【发布时间】:2011-07-14 11:51:22
【问题描述】:

我想将列类型从:string 更改为:text

问题是,如果我只是这样做:

change_column :questions, :content, :text

然后架构被重写为:

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

即它采用 string 时隐含的长度

如何进行迁移并指定不应设置 :limit 以使架构读取:

t.string   "content"

我尝试将任意限制设置为 10,000,但是 a) 感觉效率低下,并且 b) 它会尝试将 :text 限制设置为 10,000。

我可以将什么选项传递给change_column 方法以确保它只使用默认限制?

【问题讨论】:

    标签: ruby-on-rails migration


    【解决方案1】:

    Ack,在发布问题后通过反复试验发现了这一点:

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

    【讨论】:

      猜你喜欢
      • 2021-04-22
      • 1970-01-01
      • 1970-01-01
      • 2016-09-28
      • 1970-01-01
      • 1970-01-01
      • 2018-06-18
      • 1970-01-01
      • 2017-07-28
      相关资源
      最近更新 更多