假设我在Rails迁移中创建了一个表,指定省略ID列:
- create_table :categories_posts,:id => false do |t|
- t.column :category_id,:integer,:null => false
- t.column :post_id,:null => false
- end
后来我决定将ID列添加为主键,因此我创建了一个新的迁移:
- class ChangeCategoriesToRichJoin < ActiveRecord::Migration
- def self.up
- add_column :categories_posts,:id,:primary_key
- end
- def self.down
- remove_column :categories_posts,:id
- end
- end
但是当我迁移后查看表格时,它看起来像这样:
- category_id
- post_id
- id
id列位于表中的最后一个位置,而通常id列是第一个.
有没有办法更改ChangeCategoriesToRichJoin迁移以坚持在表中的category_id列之前创建的id列?