How do I retroactively add a primary key to my table in rails?

后端 未结 4 1427
眼角桃花
眼角桃花 2021-02-06 22:07

I\'ve created a table without a primary key (:id => false), but now it has come back to bite my ass.

My app is already in production and I can\'t just drop it and recre

4条回答
  •  孤独总比滥情好
    2021-02-06 23:08

    I know in mySQl that you can add a column that has a default increment value. If you add that then each row will have a unique int value (and any new row will get a int value 1 greater then the last row added)

    You could add this column and set it as a primary key.

提交回复
热议问题