我有两个桌子一种产品和另一种用法
Product
# id :integer not null, primary key
# product_name :string not null
# plan_id :string
# plan_name :string
Usage
# id :integer not null, primary key
# quantity :float
# date :date
要在使用中将product_id添加为外键
我正在尝试运行迁移
def change
add_reference(:usages, :products, foreign_key: { on_delete: :cascade })
end
不存在外键约束中引用的错误列“ product_id”,]
我有两个表,一个产品,另一种用法,产品#id:整数不为null,主键#product_name:string不为null#plan_id:string#...
解决方案的ref_name应该是单数