rails unique index on multiple columns fails (sqlite3)

后端 未结 2 699
星月不相逢
星月不相逢 2021-01-24 08:36

Using rails, I set up a HATBM model with a users table, a groups table and a groups_users for the joins (all with scaffold command). Now I want to add a migration to add a uniqu

2条回答
  •  礼貌的吻别
    2021-01-24 08:50

    Your "groups_users" table has duplicate data in it so you'd have to either manually clear out the dupes or just reset your database with rake db:reset.

    Once you've cleared the duplicates, either by removing all the data from the database or finding the dupes, you should be able to run rake db:migrate without error.

    PS, make sure you have a backup of your db before you run the command above because it is destructive.

提交回复
热议问题