# 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. # # Note that this schema.rb definition is the authoritative source for your # database schema. If you need to create the application database on another # system, you should be using db:schema:load, not running all the migrations # from scratch. The latter is a flawed and unsustainable approach (the more migrations # you'll amass, the slower it'll run and the greater likelihood for issues). # # It's strongly recommended that you check this file into your version control system. ActiveRecord::Schema.define(version: 20180401110018) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" create_table "mks_auth_application_modules", id: :serial, force: :cascade do |t| t.string "code", null: false t.string "name", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false end create_table "mks_auth_menus", id: :serial, force: :cascade do |t| t.string "text", null: false t.string "icon_cls" t.string "class_name" t.string "location" t.integer "parent_id" t.integer "application_module_id" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["application_module_id"], name: "index_mks_auth_menus_on_application_module_id" t.index ["parent_id"], name: "index_mks_auth_menus_on_parent_id" end create_table "mks_auth_menus_user_roles", id: :serial, force: :cascade do |t| t.integer "menu_id" t.integer "user_role_id" t.index ["menu_id", "user_role_id"], name: "index_mks_auth_menus_user_roles_on_menu_id_and_user_role_id" end create_table "mks_auth_user_roles", id: :serial, force: :cascade do |t| t.string "name", null: false t.integer "application_module_id" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["application_module_id"], name: "index_mks_auth_user_roles_on_application_module_id" end create_table "mks_auth_users", id: :serial, force: :cascade do |t| t.string "first_name", null: false t.string "last_name", null: false t.string "email", null: false t.boolean "active", default: true, null: false t.string "password_digest" t.datetime "created_at", null: false t.datetime "updated_at", null: false end create_table "mks_auth_users_application_modules", id: false, force: :cascade do |t| t.bigint "user_id" t.bigint "application_module_id" t.index ["user_id", "application_module_id"], name: "am_on_users_indx" end create_table "mks_auth_users_user_roles", id: false, force: :cascade do |t| t.integer "user_id" t.integer "user_role_id" t.index ["user_id", "user_role_id"], name: "index_mks_auth_users_user_roles_on_user_id_and_user_role_id" end create_table "mks_edm_equipment_categories", force: :cascade do |t| t.string "code" t.string "name", null: false t.string "description" t.bigint "equipment_type_id" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["equipment_type_id"], name: "ec_on_et_indx" end create_table "mks_edm_equipment_components", force: :cascade do |t| t.string "serial_no" t.string "name", null: false t.bigint "equipment_item_id" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["equipment_item_id"], name: "ei_on_ec_indx" end create_table "mks_edm_equipment_items", force: :cascade do |t| t.string "code" t.string "name", null: false t.string "description" t.string "status", default: "READY" t.string "serial_number" t.string "brand" t.string "item_model" t.float "purchase_price", null: false t.date "purchase_date", null: false t.float "license_fee" t.float "tax" t.bigint "equipment_id" t.bigint "current_location_id" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["current_location_id"], name: "equipment_on_el_indx" t.index ["equipment_id"], name: "equipment_on_ei_indx" end create_table "mks_edm_equipment_locations", force: :cascade do |t| t.string "code" t.string "name", null: false t.bigint "location_type_id" t.string "description" t.string "address" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["location_type_id"], name: "lt_on_el_indx" end create_table "mks_edm_equipment_types", force: :cascade do |t| t.string "code" t.string "name", null: false t.string "description" t.datetime "created_at", null: false t.datetime "updated_at", null: false end create_table "mks_edm_equipment_valuations", force: :cascade do |t| t.bigint "equipment_item_id" t.float "initial_cost", null: false t.float "residual_value", null: false t.float "work_hrs_per_yr", null: false t.float "life_year", null: false t.float "insurance_premium", null: false t.float "fuel_cost_per_hr" t.float "oil_rate" t.float "repair_rate" t.float "rate_of_return" t.string "dep_method" t.boolean "is_current", default: true t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["equipment_item_id"], name: "ev_on_ei_indx" end create_table "mks_edm_equipments", force: :cascade do |t| t.string "code" t.string "name", null: false t.string "description" t.float "minimum_acquisition_time", default: 0.0, null: false t.bigint "equipment_category_id" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["equipment_category_id"], name: "equipment_on_ec_indx" end create_table "mks_edm_location_types", force: :cascade do |t| t.string "code" t.string "name" t.string "description" t.datetime "created_at", null: false t.datetime "updated_at", null: false end create_table "mks_maintenance_cost_types", force: :cascade do |t| t.string "code" t.string "name" t.json "fields", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false end create_table "mks_maintenance_job_cards", force: :cascade do |t| t.bigint "maintenance_service_order_id" t.string "code" t.date "start_date" t.date "due_date" t.bigint "service_provider_id" t.date "checkout_date" t.bigint "checkout_by_id" t.bigint "checkout_to_id" t.bigint "maintenance_status_id" t.date "checkin_date" t.bigint "checkin_by_id" t.bigint "checkin_to_id" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.boolean "approved", default: false t.boolean "checkout_confirmed", default: false t.boolean "checkin_confirmed", default: false t.boolean "costs_approved", default: false t.integer "prepared_by_id" t.index ["checkin_by_id"], name: "chb_on_jc_indx" t.index ["checkin_to_id"], name: "cht_on_jc_indx" t.index ["checkout_by_id"], name: "cb_on_jc_indx" t.index ["checkout_to_id"], name: "ct_on_jc_indx" t.index ["maintenance_service_order_id"], name: "mso_on_jc_indx" t.index ["maintenance_status_id"], name: "ms_on_jc_indx" t.index ["service_provider_id"], name: "sp_on_jc_indx" end create_table "mks_maintenance_maintenance_categories", force: :cascade do |t| t.string "code" t.string "name" t.string "description" t.datetime "created_at", null: false t.datetime "updated_at", null: false end create_table "mks_maintenance_maintenance_costs", force: :cascade do |t| t.bigint "job_card_id" t.bigint "cost_type_id" t.json "cost_detail", null: false t.string "remark" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["cost_type_id"], name: "ct_on_mc_indx" t.index ["job_card_id"], name: "jc_on_mc_indx" end create_table "mks_maintenance_maintenance_service_orders", force: :cascade do |t| t.string "title", null: false t.string "description" t.bigint "equipment_item_id" t.bigint "maintenance_type_id" t.date "start_date" t.date "end_date" t.bigint "prepared_by_id" t.boolean "approved", default: false t.string "status", default: "draft" t.bigint "approved_by_id" t.string "remark" t.float "current_reading", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["approved_by_id"], name: "ab_on_mso_indx" t.index ["equipment_item_id"], name: "ei_on_mso_indx" t.index ["maintenance_type_id"], name: "mt_on_mso_indx" t.index ["prepared_by_id"], name: "pb_on_mso_indx" end create_table "mks_maintenance_maintenance_statuses", force: :cascade do |t| t.string "code" t.string "name" t.string "description" t.datetime "created_at", null: false t.datetime "updated_at", null: false end create_table "mks_maintenance_maintenance_types", force: :cascade do |t| t.string "code" t.string "name", null: false t.string "description" t.bigint "maintenance_category_id" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["maintenance_category_id"], name: "mt_on_mc_indx" end create_table "mks_maintenance_schedule_settings", force: :cascade do |t| t.bigint "equipment_id" t.bigint "maintenance_type_id" t.bigint "schedule_unit_id" t.float "value", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["equipment_id"], name: "equipment_on_ss_indx" t.index ["maintenance_type_id"], name: "mt_on_ss_indx" t.index ["schedule_unit_id"], name: "su_on_ss_indx" end create_table "mks_maintenance_schedule_units", force: :cascade do |t| t.string "code" t.string "name" t.string "description" t.datetime "created_at", null: false t.datetime "updated_at", null: false end create_table "mks_rate_chargeable_service_discounts", force: :cascade do |t| t.string "unit_variable", null: false t.float "from", null: false t.float "to", null: false t.float "value", null: false t.integer "chargeable_service_id" t.datetime "created_at", null: false t.datetime "updated_at", null: false end create_table "mks_rate_chargeable_services", force: :cascade do |t| t.string "code", null: false t.string "name", null: false t.integer "service_type_id" t.integer "base_unit_id" t.integer "utilization_unit_id" t.integer "service_delivery_unit_id" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["base_unit_id"], name: "bu_on_cs_indx" t.index ["service_delivery_unit_id"], name: "sdu_on_cs_indx" t.index ["service_type_id"], name: "st_on_cs_indx" t.index ["utilization_unit_id"], name: "uu_on_cs_indx" end create_table "mks_rate_rate_change_requests", force: :cascade do |t| t.string "reference_number" t.string "authorized_by", null: false t.date "effective_on", null: false t.date "authorized_on", null: false t.json "rates", null: false t.string "status", default: "SUBMITTED", null: false t.bigint "created_by_id" t.bigint "approved_by_id" t.string "remark" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["approved_by_id"], name: "ab_on_rcr_indx" t.index ["created_by_id"], name: "cb_on_rcr_indx" t.index ["reference_number"], name: "index_mks_rate_rate_change_requests_on_reference_number", unique: true end create_table "mks_rate_service_bundles", force: :cascade do |t| t.string "code" t.string "name", null: false t.string "description" t.float "percent_discount", default: 0.0, null: false t.bigint "service_delivery_unit_id" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["service_delivery_unit_id"], name: "sdu_on_sb_indx" end create_table "mks_rate_service_bundles_chargeable_services", id: false, force: :cascade do |t| t.bigint "service_bundle_id" t.bigint "chargeable_service_id" t.index ["service_bundle_id", "chargeable_service_id"], name: "sb_on_cs_indx" end create_table "mks_rate_service_delivery_units", force: :cascade do |t| t.string "code", null: false t.string "name", null: false t.string "address", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false end create_table "mks_rate_service_rates", force: :cascade do |t| t.bigint "chargeable_service_id" t.bigint "equipment_item_id" t.float "base_rate", default: 0.0 t.float "utilization_rate", default: 0.0 t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["chargeable_service_id"], name: "cs_on_sr_indx" t.index ["equipment_item_id"], name: "cs_on_ei_indx" end create_table "mks_rate_service_types", force: :cascade do |t| t.string "code" t.string "name" t.datetime "created_at", null: false t.datetime "updated_at", null: false end create_table "mks_rate_unit_of_charges", force: :cascade do |t| t.string "name", null: false t.json "unit_variables", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false end create_table "mks_rent_clients", force: :cascade do |t| t.string "name", null: false t.string "address" t.datetime "created_at", null: false t.datetime "updated_at", null: false end create_table "mks_rent_offer_requests", force: :cascade do |t| t.bigint "client_id" t.string "description" t.string "destination" t.bigint "prepared_by_id" t.string "status", default: "DRAFT", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["client_id"], name: "client_on_er_indx" t.index ["prepared_by_id"], name: "equipment_on_rb_indx" end add_foreign_key "mks_auth_menus", "mks_auth_application_modules", column: "application_module_id" add_foreign_key "mks_auth_menus", "mks_auth_menus", column: "parent_id" add_foreign_key "mks_auth_menus_user_roles", "mks_auth_menus", column: "menu_id" add_foreign_key "mks_auth_menus_user_roles", "mks_auth_user_roles", column: "user_role_id" add_foreign_key "mks_auth_user_roles", "mks_auth_application_modules", column: "application_module_id" add_foreign_key "mks_auth_users_application_modules", "mks_auth_application_modules", column: "application_module_id" add_foreign_key "mks_auth_users_application_modules", "mks_auth_users", column: "user_id" add_foreign_key "mks_auth_users_user_roles", "mks_auth_user_roles", column: "user_role_id" add_foreign_key "mks_auth_users_user_roles", "mks_auth_users", column: "user_id" add_foreign_key "mks_edm_equipment_categories", "mks_edm_equipment_types", column: "equipment_type_id" add_foreign_key "mks_edm_equipment_components", "mks_edm_equipment_items", column: "equipment_item_id" add_foreign_key "mks_edm_equipment_items", "mks_edm_equipment_locations", column: "current_location_id" add_foreign_key "mks_edm_equipment_items", "mks_edm_equipments", column: "equipment_id" add_foreign_key "mks_edm_equipment_locations", "mks_edm_location_types", column: "location_type_id" add_foreign_key "mks_edm_equipment_valuations", "mks_edm_equipment_items", column: "equipment_item_id" add_foreign_key "mks_edm_equipments", "mks_edm_equipment_categories", column: "equipment_category_id" add_foreign_key "mks_maintenance_job_cards", "mks_auth_users", column: "checkin_by_id" add_foreign_key "mks_maintenance_job_cards", "mks_auth_users", column: "checkout_by_id" add_foreign_key "mks_maintenance_job_cards", "mks_auth_users", column: "prepared_by_id" add_foreign_key "mks_maintenance_job_cards", "mks_edm_equipment_locations", column: "checkin_to_id" add_foreign_key "mks_maintenance_job_cards", "mks_edm_equipment_locations", column: "checkout_to_id" add_foreign_key "mks_maintenance_job_cards", "mks_edm_equipment_locations", column: "service_provider_id" add_foreign_key "mks_maintenance_job_cards", "mks_maintenance_maintenance_service_orders", column: "maintenance_service_order_id" add_foreign_key "mks_maintenance_job_cards", "mks_maintenance_maintenance_statuses", column: "maintenance_status_id" add_foreign_key "mks_maintenance_maintenance_service_orders", "mks_auth_users", column: "approved_by_id" add_foreign_key "mks_maintenance_maintenance_service_orders", "mks_auth_users", column: "prepared_by_id" add_foreign_key "mks_maintenance_maintenance_service_orders", "mks_edm_equipment_items", column: "equipment_item_id" add_foreign_key "mks_maintenance_maintenance_service_orders", "mks_maintenance_maintenance_types", column: "maintenance_type_id" add_foreign_key "mks_maintenance_maintenance_types", "mks_maintenance_maintenance_categories", column: "maintenance_category_id" add_foreign_key "mks_maintenance_schedule_settings", "mks_edm_equipments", column: "equipment_id" add_foreign_key "mks_maintenance_schedule_settings", "mks_maintenance_maintenance_types", column: "maintenance_type_id" add_foreign_key "mks_maintenance_schedule_settings", "mks_maintenance_schedule_units", column: "schedule_unit_id" add_foreign_key "mks_rate_chargeable_service_discounts", "mks_rate_chargeable_services", column: "chargeable_service_id" add_foreign_key "mks_rate_chargeable_services", "mks_rate_service_delivery_units", column: "service_delivery_unit_id" add_foreign_key "mks_rate_chargeable_services", "mks_rate_service_types", column: "service_type_id" add_foreign_key "mks_rate_chargeable_services", "mks_rate_unit_of_charges", column: "base_unit_id" add_foreign_key "mks_rate_chargeable_services", "mks_rate_unit_of_charges", column: "utilization_unit_id" add_foreign_key "mks_rate_rate_change_requests", "mks_auth_users", column: "approved_by_id" add_foreign_key "mks_rate_rate_change_requests", "mks_auth_users", column: "created_by_id" add_foreign_key "mks_rate_service_bundles", "mks_rate_service_delivery_units", column: "service_delivery_unit_id" add_foreign_key "mks_rate_service_bundles_chargeable_services", "mks_rate_chargeable_services", column: "chargeable_service_id" add_foreign_key "mks_rate_service_bundles_chargeable_services", "mks_rate_service_bundles", column: "service_bundle_id" add_foreign_key "mks_rate_service_rates", "mks_edm_equipment_items", column: "equipment_item_id" add_foreign_key "mks_rate_service_rates", "mks_rate_chargeable_services", column: "chargeable_service_id" add_foreign_key "mks_rent_offer_requests", "mks_auth_users", column: "prepared_by_id" end