# 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: 20180317043420) 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_rate_bundle_discounts", force: :cascade do |t| t.bigint "chargeable_service_id" t.bigint "service_bundle_id" t.float "percent_discount", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["chargeable_service_id"], name: "cs_on_bd_indx" t.index ["service_bundle_id"], name: "sb_on_bd_indx" 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.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_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 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_rate_bundle_discounts", "mks_rate_chargeable_services", column: "chargeable_service_id" add_foreign_key "mks_rate_bundle_discounts", "mks_rate_service_bundles", column: "service_bundle_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_rates", "mks_edm_equipment_items", column: "equipment_item_id" add_foreign_key "mks_rate_service_rates", "mks_rate_chargeable_services", column: "chargeable_service_id" end