Created
May 1, 2018 09:18
-
-
Save barangerbenjamin/1f1e0270c23c0fe83828f202d74d481f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreateDoctors < ActiveRecord::Migration[5.1] | |
def change | |
create_table :doctors do |t| | |
t.string :first_name | |
t.string :last_name | |
t.timestamps | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreateInterns < ActiveRecord::Migration[5.1] | |
def change | |
create_table :interns do |t| | |
t.string :first_name | |
t.string :last_name | |
t.references :doctor, index: true | |
t.timestamps | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreatePatients < ActiveRecord::Migration[5.1] | |
def change | |
create_table :patients do |t| | |
t.string :first_name | |
t.string :last_name | |
t.timestamps | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreateConsultations < ActiveRecord::Migration[5.1] | |
def change | |
create_table :consultations do |t| | |
t.references :doctor, index: true | |
t.references :patient, index: true | |
t.timestamps | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Consultation < ActiveRecord::Base | |
belongs_to :patient | |
belongs_to :doctor | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Doctor < ActiveRecord::Base | |
has_many :interns | |
has_many :consultations | |
has_many :patients, through: :consultations | |
validates :last_name, presence: true | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Intern < ActiveRecord::Base | |
belongs_to :doctor | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Patient < ActiveRecord::Base | |
has_many :consultations | |
has_many :doctors, through: :consultations | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment