我寫了一個連接模型,它看起來像一個遷移:追溯添加主鍵的表
create_table "project_memberships", :id => false, :force => true do |t|
t.integer "user_id"
t.integer "project_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "id"
end
我想現在強行創建IDS。我必須刪除表並重新創建它,或者我可以寫一個遷移消除這個約束?
可能重複的[如何將主鍵添加到一個表在軌道](http://stackoverflow.com/questions/9644509/how-to-add-a-primary-key-to-a-table-in-rails) – ABMagil 2014-11-09 15:52:06
感謝您的注意,@ABMagil。我想在這裏留下這個問題,因爲在我的情況下,已經有一個「id」列(鏈接中不是這樣)。不過,如果這對StackOverflow社區沒有太大的區別,我很樂意關閉它。 – 2014-11-09 17:53:48