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

  create_table "activation_transaction", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t|
    t.integer "debtor", null: false
    t.integer "id_user", null: false
    t.text "xml", null: false
    t.integer "branch", null: false
    t.float "discount", limit: 53, null: false
    t.float "price", limit: 53, null: false
    t.float "total", limit: 53, null: false
    t.string "uuid", limit: 36, null: false
    t.text "cadena_original", null: false
    t.string "serie", null: false
    t.string "folio", null: false
    t.boolean "detailed", null: false
    t.float "iva", limit: 53, null: false
    t.float "subtotal", limit: 53, null: false
    t.timestamp "cancellation_date", default: -> { "CURRENT_TIMESTAMP" }, null: false
    t.string "cfdi_use", null: false
    t.string "payment_form", null: false
    t.string "payment_method", null: false
    t.string "cuenta_pago", default: "", null: false
    t.string "version", limit: 5, default: "3.3", null: false
    t.string "invoice_status", limit: 9, null: false
    t.string "paid_status", limit: 7, null: false
    t.timestamp "created_at", default: -> { "CURRENT_TIMESTAMP" }, null: false
  end

  create_table "branches", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
    t.string "branchcode"
    t.text "name"
    t.string "email"
    t.string "phone"
    t.string "address1"
    t.string "address2"
    t.string "address3"
    t.string "address4"
    t.string "address5"
    t.string "address6"
    t.string "address7"
    t.string "address8"
    t.string "address9"
    t.string "address10"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.text "certificado"
    t.text "folio"
  end

  create_table "certificates", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
    t.string "certificado"
    t.string "nocertificado"
    t.string "expedition"
    t.string "expiration"
    t.text "password"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.string "certificadokey"
  end

  create_table "cofigs", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.text "payment_method"
    t.text "payment_form"
    t.text "code_article"
    t.text "code_mesure"
    t.float "price", limit: 53, null: false
  end

  create_table "config", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t|
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
  end

  create_table "debtors", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
    t.string "debtorno"
    t.text "name"
    t.text "razon_social"
    t.string "rfc"
    t.string "email"
    t.string "phone"
    t.string "address1"
    t.string "address2"
    t.string "address3"
    t.string "address4"
    t.string "address5"
    t.string "address6"
    t.string "address7"
    t.string "address8"
    t.string "address9"
    t.string "address10"
    t.string "cuenta", null: false
    t.integer "descuento", null: false
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.text "uso_cfdi"
    t.string "metodo_pago", limit: 3, null: false
    t.string "forma_pago", limit: 2, null: false
  end

  create_table "fiscals", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
    t.string "rfc"
    t.text "razon_fiscal"
    t.string "email"
    t.string "phone"
    t.string "address1"
    t.string "address2"
    t.string "address3"
    t.string "address4"
    t.string "address5"
    t.string "address6"
    t.string "address7"
    t.string "address8"
    t.string "address9"
    t.string "address10"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.text "regimen_fiscal"
    t.integer "matriz", null: false
  end

  create_table "folios", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
    t.string "code"
    t.integer "initial"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
  end

  create_table "formapagos", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
  end

  create_table "mesures", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
  end

  create_table "metodo_pagos", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
  end

  create_table "orders", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t|
    t.string "status"
    t.string "quantity"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
  end

  create_table "regimen", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
  end

  create_table "rh_clave_unidad", id: :integer, limit: 3, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", comment: "Listado de las claves de unidad, indicadas por el SAT para la versión del CFDI 3.3" do |t|
    t.string "clave", limit: 3, null: false
    t.string "nombre", limit: 250, null: false
    t.string "simbolo", limit: 100
  end

  create_table "rh_colonia", primary_key: "colcodigo", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_spanish2_ci", comment: "Listado de las colonias con su código postal" do |t|
    t.string "colcodesat", limit: 4, null: false
    t.string "colnombre", limit: 250, null: false
    t.string "colcodigopostal", limit: 5, null: false
    t.index ["colcodesat"], name: "colcodesat"
    t.index ["colcodigopostal"], name: "colcodigopostal"
  end

  create_table "rh_estado", primary_key: "edocodigo", id: :string, limit: 3, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_spanish2_ci", comment: "Listado de estados" do |t|
    t.string "edonombre", limit: 200, null: false
    t.string "paicodigo", limit: 3, null: false
    t.index ["paicodigo"], name: "FK_estado_pais"
  end

  create_table "rh_familias", id: false, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t|
    t.string "code", limit: 5, null: false
    t.string "codesegment", limit: 3, null: false
    t.string "description", limit: 200, null: false
  end

  create_table "rh_forma_pago", id: false, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
    t.string "codigo", limit: 2, null: false
    t.string "descripcion", limit: 50, null: false
    t.boolean "bancarizado", null: false
    t.date "fechainicio", null: false
    t.date "fechafin"
  end

  create_table "rh_localidad", primary_key: "loccodigo", id: :integer, default: nil, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_spanish2_ci", comment: "Listado de localidades" do |t|
    t.string "loccodesat", limit: 3, null: false
    t.string "locnombre", limit: 200, null: false
    t.string "edocodigo", limit: 3, null: false
    t.index ["edocodigo"], name: "FK_localidad_estado"
    t.index ["loccodesat"], name: "loccodesat"
  end

  create_table "rh_metodo_pago33", id: false, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
    t.string "codigo", limit: 3, null: false
    t.string "descripcion", limit: 50, null: false
    t.date "fechainicio", null: false
    t.date "fechafin"
  end

  create_table "rh_municipio", primary_key: "muncodigo", id: :integer, default: nil, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_spanish2_ci", comment: "Listado de municipios" do |t|
    t.string "muncodesat", limit: 4, null: false
    t.string "munnombre", limit: 200, null: false
    t.string "edocodigo", limit: 3, null: false
    t.index ["edocodigo"], name: "FK_municipio_estado"
    t.index ["muncodesat"], name: "muncodesat"
  end

  create_table "rh_pais", primary_key: "paicodigo", id: :string, limit: 3, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_spanish2_ci", comment: "Listado de paises" do |t|
    t.string "painombre", limit: 200, null: false
    t.integer "paiorden", limit: 2, null: false
  end

  create_table "rh_productoscat", id: false, force: :cascade, options: "ENGINE=MyISAM DEFAULT CHARSET=latin1" do |t|
    t.string "code", limit: 10, null: false
    t.string "description", limit: 200, null: false
  end

  create_table "rh_regimen_fiscal", primary_key: "clave", id: :string, limit: 3, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_spanish2_ci", comment: "Listado de regimenes fiscales" do |t|
    t.string "descripcion", limit: 250, null: false
    t.boolean "fisica", null: false
    t.boolean "moral", null: false
  end

  create_table "rh_relaciones_cp", primary_key: "colcodigopostal", id: :string, limit: 5, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_spanish2_ci", comment: "Listado de las colonias con su código postal" do |t|
    t.string "edocodigo", limit: 3, null: false
    t.string "muncodesat", limit: 4, null: false
    t.string "loccodesat", limit: 3
    t.index ["edocodigo"], name: "edocodigo"
    t.index ["loccodesat"], name: "loccodesat"
    t.index ["muncodesat"], name: "muncodesat"
  end

  create_table "rh_segmentos", id: false, force: :cascade, options: "ENGINE=MyISAM DEFAULT CHARSET=latin1" do |t|
    t.string "codeSegment", limit: 2, null: false
    t.string "description", limit: 200, null: false
  end

  create_table "rh_uso_cfdi", id: false, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
    t.string "codigo", limit: 3, null: false
    t.string "descripcion", limit: 100, null: false
    t.boolean "fisica", null: false
    t.boolean "moral", null: false
    t.date "fechainicio", null: false
    t.date "fechafin"
  end

  create_table "sessions", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t|
    t.string "session_id", null: false
    t.text "data"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.index ["session_id"], name: "index_sessions_on_session_id", unique: true
    t.index ["updated_at"], name: "index_sessions_on_updated_at"
  end

  create_table "transactions", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
    t.string "token", default: "", null: false
    t.string "status"
  end

  create_table "users", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" 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.datetime "remember_created_at"
    t.integer "sign_in_count", default: 0, null: false
    t.datetime "current_sign_in_at"
    t.datetime "last_sign_in_at"
    t.string "current_sign_in_ip"
    t.string "last_sign_in_ip"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.text "photo"
    t.string "role_user", default: "admin", 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
  end

  create_table "usos", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
  end

  add_foreign_key "rh_estado", "rh_pais", column: "paicodigo", primary_key: "paicodigo", name: "FK_estado_pais"
  add_foreign_key "rh_localidad", "rh_estado", column: "edocodigo", primary_key: "edocodigo", name: "FK_localidad_estado"
  add_foreign_key "rh_municipio", "rh_estado", column: "edocodigo", primary_key: "edocodigo", name: "FK_municipio_estado"
end
