# encoding: UTF-8
# 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: 20160728040129) do

  create_table "admin_permissions", force: :cascade do |t|
    t.string "model", limit: 255, null: false
    t.string "can",   limit: 255, null: false
  end

  create_table "admin_permissions_admin_roles", force: :cascade do |t|
    t.integer "admin_role_id",       limit: 4
    t.integer "admin_permission_id", limit: 4
  end

  add_index "admin_permissions_admin_roles", ["admin_role_id", "admin_permission_id"], name: "idx_admin_permissions_roles_id", using: :btree
  add_index "admin_permissions_admin_roles", ["admin_role_id", "admin_permission_id"], name: "idx_admin_roles_id", using: :btree

  create_table "admin_roles", force: :cascade do |t|
    t.string "name",        limit: 255,   null: false
    t.text   "description", limit: 65535
  end

  create_table "admin_roles_admin_users", force: :cascade do |t|
    t.integer "admin_role_id", limit: 4
    t.integer "admin_user_id", limit: 4
  end

  create_table "admin_users", force: :cascade do |t|
    t.string   "email",                  limit: 255, default: "",    null: false
    t.string   "encrypted_password",     limit: 255, default: "",    null: false
    t.string   "name",                   limit: 255, default: "",    null: false
    t.boolean  "is_super_admin",                     default: false, null: false
    t.string   "reset_password_token",   limit: 255
    t.datetime "reset_password_sent_at"
    t.datetime "remember_created_at"
    t.integer  "sign_in_count",          limit: 4,   default: 0
    t.datetime "current_sign_in_at"
    t.datetime "last_sign_in_at"
    t.string   "current_sign_in_ip",     limit: 255
    t.string   "last_sign_in_ip",        limit: 255
    t.datetime "created_at"
    t.datetime "updated_at"
  end

  add_index "admin_users", ["email"], name: "index_admin_users_on_email", unique: true, using: :btree
  add_index "admin_users", ["reset_password_token"], name: "index_admin_users_on_reset_password_token", unique: true, using: :btree

  create_table "ckeditor_assets", force: :cascade do |t|
    t.string   "data_file_name",    limit: 255, null: false
    t.string   "data_content_type", limit: 255
    t.integer  "data_file_size",    limit: 4
    t.integer  "assetable_id",      limit: 4
    t.string   "assetable_type",    limit: 30
    t.string   "type",              limit: 30
    t.integer  "width",             limit: 4
    t.integer  "height",            limit: 4
    t.datetime "created_at"
    t.datetime "updated_at"
  end

  add_index "ckeditor_assets", ["assetable_type", "assetable_id"], name: "idx_ckeditor_assetable", using: :btree
  add_index "ckeditor_assets", ["assetable_type", "type", "assetable_id"], name: "idx_ckeditor_assetable_type", using: :btree

  create_table "rails_admin_histories", force: :cascade do |t|
    t.text     "message",    limit: 65535
    t.string   "username",   limit: 255
    t.integer  "item",       limit: 4
    t.string   "table",      limit: 255
    t.integer  "month",      limit: 2
    t.integer  "year",       limit: 8
    t.datetime "created_at"
    t.datetime "updated_at"
  end

  add_index "rails_admin_histories", ["item", "table", "month", "year"], name: "index_rails_admin_histories", using: :btree

  create_table "rc_id_permissions", force: :cascade do |t|
    t.string   "name",          limit: 20,                     null: false
    t.string   "url_type",      limit: 20,  default: "button", null: false
    t.string   "url",           limit: 100
    t.string   "percode",       limit: 40
    t.integer  "menu_parentid", limit: 4
    t.integer  "parentid",      limit: 4
    t.string   "parentids",     limit: 100
    t.string   "sort",          limit: 20
    t.boolean  "is_available",              default: false,    null: false
    t.datetime "created_at"
    t.datetime "updated_at"
  end

  create_table "rc_id_role_permissions", force: :cascade do |t|
    t.integer  "permission_id", limit: 4, null: false
    t.integer  "role_id",       limit: 4, null: false
    t.datetime "created_at"
    t.datetime "updated_at"
  end

  add_index "rc_id_role_permissions", ["permission_id"], name: "index_wf_id_role_permissions_on_permission_id", using: :btree
  add_index "rc_id_role_permissions", ["role_id"], name: "index_wf_id_role_permissions_on_role_id", using: :btree

  create_table "rc_id_roles", force: :cascade do |t|
    t.string   "name",         limit: 20,                 null: false
    t.boolean  "is_available",            default: false, null: false
    t.datetime "created_at"
    t.datetime "updated_at"
  end

  create_table "rc_id_user_roles", force: :cascade do |t|
    t.integer  "user_id",    limit: 4, null: false
    t.integer  "role_id",    limit: 4, null: false
    t.datetime "created_at"
    t.datetime "updated_at"
  end

  add_index "rc_id_user_roles", ["role_id"], name: "index_wf_id_user_roles_on_role_id", using: :btree
  add_index "rc_id_user_roles", ["user_id"], name: "index_wf_id_user_roles_on_user_id", using: :btree

  create_table "session", primary_key: "session_key", force: :cascade do |t|
    t.binary  "session_data",   limit: 65535
    t.integer "session_expiry", limit: 4,     null: false
  end

  create_table "token", force: :cascade do |t|
    t.string   "token",        limit: 255, default: "", null: false
    t.integer  "user_id",      limit: 8,                null: false
    t.datetime "created",                               null: false
    t.datetime "updated",                               null: false
    t.integer  "expired_time", limit: 8,                null: false
  end

  add_index "token", ["token"], name: "token", unique: true, using: :btree
  add_index "token", ["user_id"], name: "user_id", unique: true, using: :btree

  create_table "user", force: :cascade do |t|
    t.string   "username", limit: 255, default: "",       null: false
    t.string   "password", limit: 255, default: "",       null: false
    t.string   "realname", limit: 255, default: "",       null: false
    t.datetime "created",                                 null: false
    t.datetime "updated",                                 null: false
    t.string   "status",   limit: 20,  default: "active", null: false
  end

  add_index "user", ["username"], name: "username", unique: true, using: :btree

  create_table "version_associations", force: :cascade do |t|
    t.integer "version_id",       limit: 4
    t.string  "foreign_key_name", limit: 255, null: false
    t.integer "foreign_key_id",   limit: 4
  end

  add_index "version_associations", ["foreign_key_name", "foreign_key_id"], name: "index_version_associations_on_foreign_key", using: :btree
  add_index "version_associations", ["version_id"], name: "index_version_associations_on_version_id", using: :btree

  create_table "versions", force: :cascade do |t|
    t.string   "item_type",      limit: 191,        null: false
    t.integer  "item_id",        limit: 4,          null: false
    t.string   "event",          limit: 255,        null: false
    t.string   "whodunnit",      limit: 255
    t.text     "object",         limit: 4294967295
    t.datetime "created_at"
    t.text     "object_changes", limit: 4294967295
    t.integer  "transaction_id", limit: 4
  end

  add_index "versions", ["item_type", "item_id"], name: "index_versions_on_item_type_and_item_id", using: :btree
  add_index "versions", ["transaction_id"], name: "index_versions_on_transaction_id", using: :btree

end
