From 9a326cf651b74fe8a03aa6aadf1f52a7ae5be5ef Mon Sep 17 00:00:00 2001 From: mo khan Date: Sun, 29 Mar 2020 12:23:44 -0600 Subject: Fix model --- rvh/app/models/laboratory.rb | 2 +- rvh/app/models/physician.rb | 2 +- rvh/app/models/shift.rb | 2 +- rvh/db/migrate/20200315182410_create_shifts.rb | 2 +- rvh/db/migrate/mple_postgres | 0 rvh/db/schema.rb | 6 +++--- 6 files changed, 7 insertions(+), 7 deletions(-) delete mode 100644 rvh/db/migrate/mple_postgres diff --git a/rvh/app/models/laboratory.rb b/rvh/app/models/laboratory.rb index 5890c95..5270a28 100644 --- a/rvh/app/models/laboratory.rb +++ b/rvh/app/models/laboratory.rb @@ -1,3 +1,3 @@ class Laboratory < ApplicationRecord - has_many :employees, -> { where(type: Technician.name) } + has_many :staff, -> { where(type: Technician.name) } end diff --git a/rvh/app/models/physician.rb b/rvh/app/models/physician.rb index 85d6605..75b218f 100644 --- a/rvh/app/models/physician.rb +++ b/rvh/app/models/physician.rb @@ -1,4 +1,4 @@ class Physician < Staff has_many :patients - has_many :treatmeants, through: :patients + has_many :treatments, through: :patients end diff --git a/rvh/app/models/shift.rb b/rvh/app/models/shift.rb index df7adc2..6e7e93a 100644 --- a/rvh/app/models/shift.rb +++ b/rvh/app/models/shift.rb @@ -1,4 +1,4 @@ class Shift < ApplicationRecord belongs_to :care_centre - belongs_to :employee + belongs_to :staff, polymorphic: true end diff --git a/rvh/db/migrate/20200315182410_create_shifts.rb b/rvh/db/migrate/20200315182410_create_shifts.rb index 7a7cca5..2f89f30 100644 --- a/rvh/db/migrate/20200315182410_create_shifts.rb +++ b/rvh/db/migrate/20200315182410_create_shifts.rb @@ -2,7 +2,7 @@ class CreateShifts < ActiveRecord::Migration[6.0] def change create_table :shifts do |t| t.references :care_centre, null: false, foreign_key: true - t.references :employee, null: false, foreign_key: true + t.references :staff, polymorphic: true, null: false t.datetime :started_at, null: false t.datetime :ended_at diff --git a/rvh/db/migrate/mple_postgres b/rvh/db/migrate/mple_postgres deleted file mode 100644 index e69de29..0000000 diff --git a/rvh/db/schema.rb b/rvh/db/schema.rb index 7e2d0b3..50828d5 100644 --- a/rvh/db/schema.rb +++ b/rvh/db/schema.rb @@ -86,13 +86,14 @@ ActiveRecord::Schema.define(version: 2020_03_15_190540) do create_table "shifts", force: :cascade do |t| t.bigint "care_centre_id", null: false - t.bigint "employee_id", null: false + t.string "staff_type", null: false + t.bigint "staff_id", null: false t.datetime "started_at", null: false t.datetime "ended_at" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false t.index ["care_centre_id"], name: "index_shifts_on_care_centre_id" - t.index ["employee_id"], name: "index_shifts_on_employee_id" + t.index ["staff_type", "staff_id"], name: "index_shifts_on_staff_type_and_staff_id" end create_table "staff", force: :cascade do |t| @@ -144,7 +145,6 @@ ActiveRecord::Schema.define(version: 2020_03_15_190540) do add_foreign_key "patients", "staff", column: "physician_id" add_foreign_key "patients", "staff", column: "referring_physician_id" add_foreign_key "shifts", "care_centres" - add_foreign_key "shifts", "staff" add_foreign_key "staff", "accounts" add_foreign_key "staff", "laboratories" add_foreign_key "treatments", "patients" -- cgit v1.2.3