summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo.khan@gmail.com>2020-03-15 12:20:11 -0600
committermo khan <mo.khan@gmail.com>2020-03-15 12:20:11 -0600
commit87ef7d3c9cab6958c7d2c480edfe619bcab36e80 (patch)
treef61f9c555dfecc202ec69e12c2ef023fab0d19cb
parent57724273c31cc034d98b47ff3dcbfc9ac4a2ce9e (diff)
Create care centres
-rw-r--r--rvh/app/models/care_centre.rb3
-rw-r--r--rvh/app/models/employee.rb2
-rw-r--r--rvh/app/models/nurse.rb3
-rw-r--r--rvh/db/migrate/20200315180659_create_nurses.rb11
-rw-r--r--rvh/db/migrate/20200315180939_create_care_centres.rb11
-rw-r--r--rvh/db/migrate/20200315181211_create_employees.rb11
-rw-r--r--rvh/db/schema.rb22
7 files changed, 42 insertions, 21 deletions
diff --git a/rvh/app/models/care_centre.rb b/rvh/app/models/care_centre.rb
new file mode 100644
index 0000000..08767dc
--- /dev/null
+++ b/rvh/app/models/care_centre.rb
@@ -0,0 +1,3 @@
+class CareCentre < ApplicationRecord
+ belongs_to :employee, polymorphic: true
+end
diff --git a/rvh/app/models/employee.rb b/rvh/app/models/employee.rb
new file mode 100644
index 0000000..d5e0233
--- /dev/null
+++ b/rvh/app/models/employee.rb
@@ -0,0 +1,2 @@
+class Employee < ApplicationRecord
+end
diff --git a/rvh/app/models/nurse.rb b/rvh/app/models/nurse.rb
deleted file mode 100644
index 483b229..0000000
--- a/rvh/app/models/nurse.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-class Nurse < ApplicationRecord
- belongs_to :account
-end
diff --git a/rvh/db/migrate/20200315180659_create_nurses.rb b/rvh/db/migrate/20200315180659_create_nurses.rb
deleted file mode 100644
index fdfa932..0000000
--- a/rvh/db/migrate/20200315180659_create_nurses.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-class CreateNurses < ActiveRecord::Migration[6.0]
- def change
- create_table :nurses do |t|
- t.references :account, null: false, foreign_key: true
- t.datetime :hired_at, null: false
- t.string :certification
-
- t.timestamps
- end
- end
-end
diff --git a/rvh/db/migrate/20200315180939_create_care_centres.rb b/rvh/db/migrate/20200315180939_create_care_centres.rb
new file mode 100644
index 0000000..42c0884
--- /dev/null
+++ b/rvh/db/migrate/20200315180939_create_care_centres.rb
@@ -0,0 +1,11 @@
+class CreateCareCentres < ActiveRecord::Migration[6.0]
+ def change
+ create_table :care_centres do |t|
+ t.references :employee, polymorphic: true, null: false
+ t.string :name
+ t.string :location
+
+ t.timestamps
+ end
+ end
+end
diff --git a/rvh/db/migrate/20200315181211_create_employees.rb b/rvh/db/migrate/20200315181211_create_employees.rb
new file mode 100644
index 0000000..4fcbd76
--- /dev/null
+++ b/rvh/db/migrate/20200315181211_create_employees.rb
@@ -0,0 +1,11 @@
+class CreateEmployees < ActiveRecord::Migration[6.0]
+ def change
+ create_table :employees do |t|
+ t.string :type
+ t.datetime :hired_at
+
+ t.timestamps
+ end
+ add_index :employees, :type
+ end
+end
diff --git a/rvh/db/schema.rb b/rvh/db/schema.rb
index b66177d..d333f5e 100644
--- a/rvh/db/schema.rb
+++ b/rvh/db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 2020_03_15_180659) do
+ActiveRecord::Schema.define(version: 2020_03_15_181211) do
create_table "accounts", force: :cascade do |t|
t.string "name", null: false
@@ -21,13 +21,22 @@ ActiveRecord::Schema.define(version: 2020_03_15_180659) do
t.datetime "updated_at", precision: 6, null: false
end
- create_table "nurses", force: :cascade do |t|
- t.integer "account_id", null: false
- t.datetime "hired_at", null: false
- t.string "certification"
+ create_table "care_centres", force: :cascade do |t|
+ t.string "employee_type", null: false
+ t.integer "employee_id", null: false
+ t.string "name"
+ t.string "location"
+ t.datetime "created_at", precision: 6, null: false
+ t.datetime "updated_at", precision: 6, null: false
+ t.index ["employee_type", "employee_id"], name: "index_care_centres_on_employee_type_and_employee_id"
+ end
+
+ create_table "employees", force: :cascade do |t|
+ t.string "type"
+ t.datetime "hired_at"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
- t.index ["account_id"], name: "index_nurses_on_account_id"
+ t.index ["type"], name: "index_employees_on_type"
end
create_table "patients", force: :cascade do |t|
@@ -38,6 +47,5 @@ ActiveRecord::Schema.define(version: 2020_03_15_180659) do
t.index ["account_id"], name: "index_patients_on_account_id"
end
- add_foreign_key "nurses", "accounts"
add_foreign_key "patients", "accounts"
end