I understand that by default the id
field is created and also: PRIMARY KEY (
id)
.
How about the foreign key ?
I have Shops
and Products
tables and the following associations:
Shop: has_many :products
Product: belongs_to :shop
In Product
I have also:
t.integer "shop_id"
which is meant to be the foreign key, and also:
add_index("products", "shop_id")
However, if I export the database I see only:
KEY `index_products_on_shop_id` (`shop_id`)
What should I do in order to add
FOREIGN KEY (`shop_id`) REFERENCES Shop(`id`)
?