【问题标题】:Is there a way to remove the id column in a subsequent Rails 3 ActiveRecord migration?有没有办法在后续 Rails 3 ActiveRecord 迁移中删除 id 列?
【发布时间】:2012-01-13 17:18:18
【问题描述】:

在 Rails 3 ActiveRecord create_table 中是否可以包含选项 :id => false。例如

create_table :posts, :id => false do |t|
...
end

但是否可以在后续向上迁移中删除现有表上的 :id 列?

【问题讨论】:

    标签: ruby-on-rails activerecord


    【解决方案1】:

    您应该能够像删除任何其他非 ID 列一样删除该列:

    remove_column :posts, :id
    

    【讨论】:

      猜你喜欢
      • 2010-10-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多