如何在 Rails 3 中使用迁移指定要添加的字段顺序? [英] How to specify order of field to add using migration in Rails 3?

查看:47
本文介绍了如何在 Rails 3 中使用迁移指定要添加的字段顺序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何指定要在哪个字段之后添加新列?(我不希望在时间戳后的底部添加字段)

How can I specify after which field I want to add a new column? (I don't want the field added in at the bottom after the timestamps)

add_column :users, :is_active, :boolean

推荐答案

方法如下:

add_column :users, :is_active, :boolean, :after => :some_column

其中 :some_column 是您要添加 :is_active 的列的名称.

where :some_column is the name of the column you want to add :is_active after.

这篇关于如何在 Rails 3 中使用迁移指定要添加的字段顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆