If you had this in Rails 4:
t.references :event, index: true
Now you could use foreign_key
instead of index
in Rails
The index
and foreign_key
are different concepts, even if in Rails 5. So it's wrong to say the rails 5 changed “index” to “foreign key”.
The change from Rails 4 to Rails 5 is that the index
option defaults to true
, so you don't need to set it explicitly.
Method add_reference in rails 4.2.5
:index
Add an appropriate index. Defaults to false.
Method add_reference in rails 5.2
:index
Add an appropriate index. Defaults to true. See add_index for usage of this option.
That's why when you generate the references
in rails 5 migration, you didn't see the index: true
, because it's default.