diff options
| author | mo khan <mo.khan@gmail.com> | 2020-03-15 12:41:30 -0600 |
|---|---|---|
| committer | mo khan <mo.khan@gmail.com> | 2020-03-15 12:41:30 -0600 |
| commit | d9fc812024357bbc05b4fb2b9df0509183089833 (patch) | |
| tree | 8ec82482cf934d33382484d7f70e6b5613cf02e2 /rvh/db | |
| parent | 1751eb5048052a73b486b651d302e7e9fdf738c0 (diff) | |
Record consumptions
Diffstat (limited to 'rvh/db')
| -rw-r--r-- | rvh/db/migrate/20200315183805_create_items.rb | 11 | ||||
| -rw-r--r-- | rvh/db/migrate/20200315183903_create_consumptions.rb | 13 | ||||
| -rw-r--r-- | rvh/db/schema.rb | 24 |
3 files changed, 47 insertions, 1 deletions
diff --git a/rvh/db/migrate/20200315183805_create_items.rb b/rvh/db/migrate/20200315183805_create_items.rb new file mode 100644 index 0000000..98242b1 --- /dev/null +++ b/rvh/db/migrate/20200315183805_create_items.rb @@ -0,0 +1,11 @@ +class CreateItems < ActiveRecord::Migration[6.0] + def change + create_table :items do |t| + t.string :sku, null: false + t.text :description + t.decimal :unit_cost, null: false + + t.timestamps + end + end +end diff --git a/rvh/db/migrate/20200315183903_create_consumptions.rb b/rvh/db/migrate/20200315183903_create_consumptions.rb new file mode 100644 index 0000000..5da1833 --- /dev/null +++ b/rvh/db/migrate/20200315183903_create_consumptions.rb @@ -0,0 +1,13 @@ +class CreateConsumptions < ActiveRecord::Migration[6.0] + def change + create_table :consumptions do |t| + t.references :patient, null: false, foreign_key: true + t.references :item, null: false, foreign_key: true + t.datetime :consumed_at, null: false + t.integer :quantity, null: false + t.decimal :total_cost, null: false + + t.timestamps + end + end +end diff --git a/rvh/db/schema.rb b/rvh/db/schema.rb index 55cd78a..1b8e238 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_183345) do +ActiveRecord::Schema.define(version: 2020_03_15_183903) do create_table "accounts", force: :cascade do |t| t.string "name", null: false @@ -41,6 +41,18 @@ ActiveRecord::Schema.define(version: 2020_03_15_183345) do t.index ["employee_type", "employee_id"], name: "index_care_centres_on_employee_type_and_employee_id" end + create_table "consumptions", force: :cascade do |t| + t.integer "patient_id", null: false + t.integer "item_id", null: false + t.datetime "consumed_at", null: false + t.integer "quantity", null: false + t.decimal "total_cost", null: false + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + t.index ["item_id"], name: "index_consumptions_on_item_id" + t.index ["patient_id"], name: "index_consumptions_on_patient_id" + end + create_table "employees", force: :cascade do |t| t.integer "account_id", null: false t.string "type" @@ -51,6 +63,14 @@ ActiveRecord::Schema.define(version: 2020_03_15_183345) do t.index ["type"], name: "index_employees_on_type" end + create_table "items", force: :cascade do |t| + t.string "sku", null: false + t.text "description" + t.decimal "unit_cost", null: false + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + end + create_table "patients", force: :cascade do |t| t.integer "account_id", null: false t.datetime "contacted_at", null: false @@ -93,6 +113,8 @@ ActiveRecord::Schema.define(version: 2020_03_15_183345) do add_foreign_key "beds", "care_centres" add_foreign_key "beds", "patients" + add_foreign_key "consumptions", "items" + add_foreign_key "consumptions", "patients" add_foreign_key "employees", "accounts" add_foreign_key "patients", "accounts" add_foreign_key "shifts", "care_centres" |
