rails g migration add foreing key code example
Example: rails g migration foreign key optionnal
#MODEL
belongs_to :author, optional: true
#MIGRATION
t.references :author, foreign_key: true
#MODEL
belongs_to :author, optional: true
#MIGRATION
t.references :author, foreign_key: true