By release of rails 4.2 add_foreign_key method was introduced. As far as I understand it is used as combo of migration with model:references
and add_index
.
Let's say I only use PostreSQL. (add_foreign_key
is limited to MySQL and PostreSQL). Should stop using migration model:references
with add_index
and start using add_foreign_key
only?. If yes/no, why?. What are benefits of new add_foreign_key
method? Is it worth to swap?
model:reference
andadd_index
. It's about adding foreign key constraint to the database. There were no such option before without raw sql or additional gems (such foreiner). – Puttadd_foreign_key
method. But, you should either usemodel:reference
ormodel_id:integer:index
parameters when generating migration. Without this you will not be able to connect two models. – Putt