# 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: 20190828015513) do

  # These are extensions that must be enabled in order to support this database
  enable_extension "plpgsql"

  create_table "access_log_details", force: :cascade do |t|
    t.bigint "access_log_id"
    t.datetime "accessed_at"
    t.string "accessed_ua"
    t.string "accessed_controller"
    t.string "accessed_action"
    t.string "accessed_purpose"
    t.boolean "accessed_result"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.text "accessed_error_detail"
    t.index ["access_log_id"], name: "index_access_log_details_on_access_log_id"
  end

  create_table "access_log_mynumbers", force: :cascade do |t|
    t.bigint "access_log_detail_id"
    t.bigint "mynumber_id"
    t.integer "key_1"
    t.string "key_2"
    t.string "key_3"
    t.boolean "export_log", default: false
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.integer "action_type"
    t.string "organization"
    t.string "unit"
    t.index ["access_log_detail_id"], name: "index_access_log_mynumbers_on_access_log_detail_id"
    t.index ["mynumber_id"], name: "index_access_log_mynumbers_on_mynumber_id"
  end

  create_table "access_logs", force: :cascade do |t|
    t.date "accessed_on"
    t.inet "accessed_ip"
    t.string "accessed_ua"
    t.string "accessed_id"
    t.string "accessed_type"
    t.string "accessed_username"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
  end

  create_table "checkways", force: :cascade do |t|
    t.string "name"
    t.integer "order_number"
    t.bigint "created_account_id"
    t.bigint "updated_account_id"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
  end

  create_table "column_name_settings", force: :cascade do |t|
    t.string "column_key"
    t.string "column_value"
    t.bigint "created_account_id"
    t.bigint "updated_account_id"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
  end

  create_table "csv_bulk_updates", force: :cascade do |t|
    t.string "csv_file"
    t.integer "status", default: 0, null: false
    t.integer "data_count", default: 0, null: false
    t.integer "success_count", default: 0, null: false
    t.text "success_data"
    t.integer "failure_count", default: 0, null: false
    t.text "failure_data"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.bigint "created_account_id"
    t.string "created_account_type"
  end

  create_table "evidence_files", force: :cascade do |t|
    t.bigint "mynumber_id"
    t.string "file_name"
    t.string "content_type"
    t.binary "file_data"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.index ["mynumber_id"], name: "index_evidence_files_on_mynumber_id"
  end

  create_table "identification_media", force: :cascade do |t|
    t.string "name"
    t.integer "order_number"
    t.bigint "created_account_id"
    t.bigint "updated_account_id"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
  end

  create_table "mynumber_csv_imports", force: :cascade do |t|
    t.string "csv_file"
    t.integer "status", default: 0, null: false
    t.integer "data_count", default: 0, null: false
    t.integer "success_count", default: 0, null: false
    t.text "success_data"
    t.integer "failure_count", default: 0, null: false
    t.text "failure_data"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.bigint "created_account_id"
    t.string "created_account_type"
  end

  create_table "mynumbers", force: :cascade do |t|
    t.string "mynumber", limit: 255
    t.date "getdate"
    t.integer "key_1"
    t.string "key_2", limit: 255
    t.string "key_3", limit: 255
    t.text "remarks"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.date "will_delete_date"
    t.bigint "created_account_id"
    t.string "created_account_type"
    t.bigint "updated_account_id"
    t.string "updated_account_type"
    t.bigint "approved_account_id"
    t.string "approved_account_type"
    t.string "checkway"
    t.string "nc_media"
    t.string "ic_media"
    t.string "note_1"
    t.string "note_2"
    t.string "organization"
    t.string "unit"
    t.integer "manage_number", default: 0, null: false
    t.index ["key_1", "key_2", "key_3"], name: "mynumber_search_index"
    t.index ["key_2", "manage_number", "key_1"], name: "mynumber_same_manage_numbers"
  end

  create_table "numbercation_media", force: :cascade do |t|
    t.string "name"
    t.integer "order_number"
    t.bigint "created_account_id"
    t.bigint "updated_account_id"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
  end

  create_table "purposes", force: :cascade do |t|
    t.string "name"
    t.integer "order_number"
    t.bigint "created_account_id"
    t.bigint "updated_account_id"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.integer "show_key"
  end

  create_table "temp_mynumbers", force: :cascade do |t|
    t.bigint "original_mynumber_id"
    t.string "mynumber"
    t.date "getdate"
    t.integer "key_1"
    t.string "key_2"
    t.string "key_3"
    t.text "remarks"
    t.bigint "created_account_id"
    t.string "created_account_type"
    t.bigint "updated_account_id"
    t.string "updated_account_type"
    t.date "will_delete_date"
    t.text "post_reason"
    t.integer "status", default: 1, null: false
    t.text "return_reason"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.string "checkway"
    t.string "nc_media"
    t.string "ic_media"
    t.index ["original_mynumber_id"], name: "index_temp_mynumbers_on_original_mynumber_id"
  end

  create_table "tenant_settings", force: :cascade do |t|
    t.string "setting_key"
    t.string "setting_value"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
  end

  create_table "tenants", force: :cascade do |t|
    t.string "name", null: false
    t.string "company_name"
    t.boolean "bpuse_flg", default: true, null: false
    t.boolean "stop_flg", default: false, null: false
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.bigint "created_account_id"
    t.bigint "updated_account_id"
    t.index ["name"], name: "index_tenants_on_name", unique: true
  end

  create_table "user_authorities", force: :cascade do |t|
    t.bigint "user_id"
    t.string "organization"
    t.string "unit"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.index ["user_id"], name: "index_user_authorities_on_user_id"
  end

  create_table "users", force: :cascade do |t|
    t.string "email", default: "", null: false
    t.string "encrypted_password", default: "", null: false
    t.string "reset_password_token"
    t.datetime "reset_password_sent_at"
    t.integer "sign_in_count", default: 0, null: false
    t.datetime "current_sign_in_at"
    t.datetime "last_sign_in_at"
    t.inet "current_sign_in_ip"
    t.inet "last_sign_in_ip"
    t.string "confirmation_token"
    t.datetime "confirmed_at"
    t.datetime "confirmation_sent_at"
    t.string "unconfirmed_email"
    t.integer "failed_attempts", default: 0, null: false
    t.string "unlock_token"
    t.datetime "locked_at"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.integer "role", default: 0, null: false
    t.string "sign_in_id"
    t.bigint "created_account_id"
    t.string "created_account_type"
    t.bigint "updated_account_id"
    t.string "updated_account_type"
    t.string "name"
    t.boolean "from_webapi", default: false, null: false
    t.index ["email"], name: "index_users_on_email", unique: true
    t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
    t.index ["sign_in_id"], name: "index_users_on_sign_in_id"
  end

  create_table "webapi_keys", force: :cascade do |t|
    t.string "app_name", limit: 255
    t.string "app_id", limit: 255
    t.string "app_token", limit: 255
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
  end

  add_foreign_key "access_log_details", "access_logs"
  add_foreign_key "access_log_mynumbers", "access_log_details"
  add_foreign_key "evidence_files", "mynumbers"
  add_foreign_key "user_authorities", "users"
end