T. References Rails
rails g migration addDoctorReferencesToPatients doctor:references
rails db:migrate
# create automatically doctor references to patients table
Lioruby
rails g migration addDoctorReferencesToPatients doctor:references
rails db:migrate
# create automatically doctor references to patients table
t.references :user, foreign_key: true # , null: false