Ruby on Rails DB 迁移脚本使用文本而不是 :string varchar
我是 Ruby on Rails 的初学者,所以如果这很明显,我深表歉意,但我正在尝试学习如何编写数据库迁移脚本,并且我想将以下 long_description 更改为文本值而不是字符串:
class CreateArticles < ActiveRecord::Migration
def self.up
create_table :articles do |t|
t.column "short_description", :string
t.column "long_description", :string
t.timestamps
end
end
end
有什么想法这怎么可能吗?
I'm a beginner at Ruby on Rails so I apologize if this is quite obvious, but I'm trying to learn how to write the database migration scripts and I'd like to change the following long_description to a text value instead of string:
class CreateArticles < ActiveRecord::Migration
def self.up
create_table :articles do |t|
t.column "short_description", :string
t.column "long_description", :string
t.timestamps
end
end
end
Any ideas how this is possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
另外,不要忘记
down
方法。此处列出了迁移类型。
Also, don't forget the
down
method.Migration types are listed here.
将其设置为 :text
这是一个很好的参考: 这里
Set it to :text
Here's a good ref for you: Here