Rails 如何调整已经创建的 model 的 column 的顺序

jl5161 · March 06, 2018 · Last by jl5161 replied at March 07, 2018 · 1689 hits

比如 之前创建的 model 在数据库中显示的为 a-b-c-d 现在想调整显示的顺序为 a-c-b-d 对应的 migration 如何写?谢谢 def change xxxx 应该如何写 end

pg 貌似是不支持的,mysql 可以,有 after 和 before 选项

change_column :users, :last_name, :string, after: :first_name

但是 pg 是不支持的。mysql 支持。其他的不清楚

Reply to mengqing

刚试了下 change_column 不生效

def change
  change_column :Accounts, :status, :integer, after: :accounttype
end

哪里不对吗?

sqlite3 不支持的是吗?

Reply to jl5161

有什么错误信息

Reply to mengqing

没有任何提示 执行正常但是无效

Reply to jl5161

sqlite3 不支持 after

You need to Sign in before reply, if you don't have an account, please Sign up first.