# This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # # This file is the source Rails uses to define your schema when running `rails # db:schema:load`. When creating a new database, `rails db:schema:load` tends to # be faster and is potentially less error prone than running all of your # migrations from scratch. Old migrations may fail to apply correctly if those # migrations use external dependencies or application code. # # It's strongly recommended that you check this file into your version control system. ActiveRecord::Schema.define(version: 2020_03_15_190540) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" create_table "accounts", force: :cascade do |t| t.string "name", null: false t.string "address", null: false t.datetime "birth_date", null: false t.string "phone_number" t.string "pager_number" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false end create_table "beds", force: :cascade do |t| t.string "bed_number" t.string "room_number" t.bigint "care_centre_id", null: false t.bigint "patient_id" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false t.index ["care_centre_id"], name: "index_beds_on_care_centre_id" t.index ["patient_id"], name: "index_beds_on_patient_id" end create_table "care_centres", force: :cascade do |t| t.bigint "nurse_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 ["nurse_id"], name: "index_care_centres_on_nurse_id" end create_table "consumptions", force: :cascade do |t| t.bigint "patient_id", null: false t.bigint "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 "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 "laboratories", force: :cascade do |t| t.string "name" t.string "location" 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.bigint "account_id", null: false t.bigint "physician_id", null: false t.bigint "referring_physician_id", null: false t.datetime "contacted_at", null: false t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false t.index ["account_id"], name: "index_patients_on_account_id", unique: true t.index ["physician_id"], name: "index_patients_on_physician_id" t.index ["referring_physician_id"], name: "index_patients_on_referring_physician_id" end create_table "shifts", force: :cascade do |t| t.bigint "care_centre_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 ["staff_type", "staff_id"], name: "index_shifts_on_staff_type_and_staff_id" end create_table "staff", force: :cascade do |t| t.bigint "account_id", null: false t.bigint "laboratory_id" t.string "type" t.datetime "hired_at" t.text "qualifications", array: true t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false t.index ["account_id"], name: "index_staff_on_account_id", unique: true t.index ["laboratory_id"], name: "index_staff_on_laboratory_id" t.index ["type"], name: "index_staff_on_type" end create_table "treatments", force: :cascade do |t| t.bigint "patient_id", null: false t.string "name", null: false t.string "number", null: false t.datetime "occurred_at", null: false t.text "results" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false t.index ["patient_id"], name: "index_treatments_on_patient_id" end create_table "visits", force: :cascade do |t| t.bigint "patient_id", null: false t.datetime "scheduled_at", null: false t.text "comments" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false t.index ["patient_id"], name: "index_visits_on_patient_id" end create_table "volunteers", force: :cascade do |t| t.bigint "account_id", null: false t.text "skill", null: false t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false t.index ["account_id"], name: "index_volunteers_on_account_id", unique: true end add_foreign_key "beds", "care_centres" add_foreign_key "beds", "patients" add_foreign_key "consumptions", "items" add_foreign_key "consumptions", "patients" add_foreign_key "patients", "accounts" 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 "staff", "accounts" add_foreign_key "staff", "laboratories" add_foreign_key "treatments", "patients" add_foreign_key "visits", "patients" add_foreign_key "volunteers", "accounts" end