且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

老外-删除外键

更新时间:2023-02-02 22:58:25

模式中的add_foreign_key命令为您的外键提供了名称notifications_on_conversation_id.此名称不同于外国人通常根据列名称指定的默认名称,该名称为notifications_conversation_id_fk.因此,您的remove_foreign_key命令必须指定现有的外键名称而不是列名称.试试:

The add_foreign_key command in your schema gave your foreign key the name notifications_on_conversation_id. This name is different than the default name that foreigner would normally assign based on the column name, which is notifications_conversation_id_fk. So your remove_foreign_key command must specify the existing foreign key name instead of the column name. Try:

remove_foreign_key :notifications, name: "notifications_on_conversation_id"