# 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 to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20120522160158) do

  create_table "companies", :force => true do |t|
    t.string   "name"
    t.integer  "industry_id"
    t.integer  "reviews_count",       :default => 0, :null => false
    t.integer  "admin_reviews_count",       :default => 0, :null => false
    t.integer  "twitter_reviews_count",       :default => 0, :null => false
    t.integer  "using_count",         :default => 0, :null => false
    t.integer  "tried_count",         :default => 0, :null => false
    t.integer  "managers_count",      :default => 0, :null => false
    t.integer  "review_approvals_count",      :default => 0, :null => false
    t.integer  "parent_id"
    t.integer  "children_count",      :default => 0, :null => false
    t.integer  "soft_delete_paranoia_count",  :default => 0, :null => false
    t.integer  "soft_delete_paranoia_values_sum", :default => 0, :null => false
    t.integer  "soft_delete_paranoia_include_soft_deleted_count", :default => 0, :null => false
    t.integer  "soft_delete_paranoia_deleted_count", :default => 0, :null => false
    t.integer  "soft_delete_discards_count",  :default => 0, :null => false
    t.integer  "soft_delete_discard_values_sum", :default => 0, :null => false
    t.integer  "soft_delete_discard_include_soft_deleted_count", :default => 0, :null => false
    t.integer  "soft_delete_discard_deleted_count", :default => 0, :null => false
    t.datetime "created_at"
    t.datetime "updated_at"
  end

  create_table "comments", :force => true do |t|
    t.string   "content"
    t.string   "commentable_type"
    t.integer  "commentable_id"
    t.integer  "comments_count",      :default => 0, :null => false
    t.integer  "soft_delete_paranoia_count",  :default => 0, :null => false
    t.integer  "soft_delete_paranoia_values_sum", :default => 0, :null => false
    t.integer  "soft_delete_paranoia_include_soft_deleted_count", :default => 0, :null => false
    t.integer  "soft_delete_paranoia_deleted_count", :default => 0, :null => false
    t.integer  "soft_delete_discards_count",  :default => 0, :null => false
    t.integer  "soft_delete_discard_values_sum", :default => 0, :null => false
    t.integer  "soft_delete_discard_include_soft_deleted_count", :default => 0, :null => false
    t.integer  "soft_delete_discard_deleted_count", :default => 0, :null => false
    t.datetime "created_at"
    t.datetime "updated_at"
  end

  create_table "industries", :force => true do |t|
    t.string   "name"
    t.integer  "reviews_count",       :default => 0, :null => false
    t.integer  "rexiews_count",       :default => 0, :null => false
    t.integer  "using_count",         :default => 0, :null => false
    t.integer  "tried_count",         :default => 0, :null => false
    t.integer  "review_approvals_count",      :default => 0, :null => false
    t.datetime "created_at"
    t.datetime "updated_at"
  end

  create_table "products", :force => true do |t|
    t.string   "name"
    t.integer  "reviews_count",               :default => 0, :null => false
    t.integer  "simple_reviews_count",        :default => 0, :null => false
    t.integer  "rexiews_count",               :default => 0, :null => false
    t.datetime "rexiews_updated_at"
    t.integer  "twitter_reviews_count",       :default => 0, :null => false
    t.integer  "category_id"
    t.datetime "created_at"
    t.datetime "updated_at"
  end

  create_table "reviews", :force => true do |t|
    t.string   "review_type",                :default => "using"
    t.string   "some_text"
    t.string   "read_only_text"
    t.integer  "user_id"
    t.integer  "admin_user_id"
    t.integer  "product_id"
    t.integer  "approvals"
    t.float    "value"
    t.boolean  "heavy",               :default => false, :null => false
    t.string   "type"
    t.datetime "created_at"
    t.datetime "updated_at"
  end

  create_table "users", :force => true do |t|
    t.string   "type"
    t.string   "name"
    t.integer  "company_id"
    t.integer  "manages_company_id"
    t.integer  "reviews_count",       :default => 0, :null => false
    t.integer  "using_count",         :default => 0, :null => false
    t.integer  "tried_count",         :default => 0, :null => false
    t.integer  "dynamic_delta_count",         :default => 0, :null => false
    t.integer  "custom_delta_count",         :default => 0, :null => false
    t.integer  "review_approvals_count",      :default => 0, :null => false
    t.string   "has_string_id_id"
    t.integer  "has_non_pk_id_id"
    t.float    "review_value_sum",    :default => 0.0, :null => false
    t.datetime "created_at"
    t.datetime "updated_at"
  end

  create_table "categories", :force => true do |t|
    t.string   "name"
    t.integer  "products_count",       :default => 0, :null => false
    t.integer  "posts_count",       :default => 0, :null => false
    t.datetime "created_at"
    t.datetime "updated_at"
  end

  create_table "has_non_pk_ids", :force => true, :id => false do |t|
    t.integer  "id", :null => false
    t.string   "something"
    t.integer  "users_count",        :null => false, :default => 0
    t.datetime "created_at"
    t.datetime "updated_at"
  end
  add_index "has_non_pk_ids", :id, :unique => true

  create_table "has_string_ids", :force => true, :id => false do |t|
    t.string   "id", :default => '', :null => false, :limit => 191
    t.string   "something"
    t.integer  "users_count",        :null => false, :default => 0
    t.datetime "created_at"
    t.datetime "updated_at"
  end
  add_index "has_string_ids", :id, :unique => true

  create_table "simple_mains", :force => true do |t|
    t.integer "simple_dependents_count", :null => false, :default => 0
    t.datetime "created_at"
    t.datetime "updated_at"
  end

  create_table "simple_dependents", :force => true do |t|
    t.integer "simple_main_id"
    t.datetime "created_at"
    t.datetime "updated_at"
  end

  create_table "conditional_mains", :force => true do |t|
    t.integer "conditional_dependents_count", :null => false, :default => 0
    t.datetime "created_at"
    t.datetime "updated_at"
  end

  create_table "conditional_dependents", :force => true do |t|
    t.integer "conditional_main_id"
    t.boolean "condition", default: false
    t.datetime "created_at"
    t.datetime "updated_at"
  end

  create_table "categs", :primary_key => "cat_id", :force => true do |t|
    t.integer  "posts_count",       :default => 0, :null => false
    t.integer  "posts_include_soft_deleted_count", :default => 0, :null => false
    t.datetime "created_at"
    t.datetime "updated_at"
  end

  create_table "subcategs", :primary_key => "subcat_id", :force => true do |t|
    t.integer  "fk_cat_id"
    t.integer  "posts_count",       :default => 0, :null => false
    t.integer  "posts_after_commit_count",       :default => 0, :null => false
    t.integer  "posts_dynamic_commit_count",       :default => 0, :null => false
    t.timestamp "discarded_at"
    t.timestamp "deleted_at"
    t.datetime "created_at"
    t.datetime "updated_at"
  end

  create_table "posts", :primary_key => "post_id", :force => true do |t|
    t.string   "title"
    t.integer  "fk_subcat_id", :default => nil
    t.integer  "comments_count", :null => false, :default => 0
    t.integer  "likes_count", :null => false, :default => 0
    t.datetime "created_at", :null => false
    t.datetime "updated_at", :null => false
  end

  create_table "post_comments", :primary_key => "post_id", :force => true do |t|
    t.string   "comment"
    t.datetime "created_at", :null => false
    t.datetime "updated_at", :null => false
  end

  create_table "post_likes", :force => true do |t|
    t.integer  "post_id", :null => false
    t.datetime "created_at", :null => false
  end

  create_table "another_posts", :force => true do |t|
    t.string   "title"
    t.integer  "another_id", :null => false
    t.integer  "another_post_comments_count", :null => false, :default => 0
    t.datetime "created_at", :null => false
    t.datetime "updated_at", :null => false
  end
  add_index "another_posts", :another_id, :unique => true

  create_table "another_post_comments", :force => true do |t|
    t.integer "another_post_id"
    t.string   "comment"
    t.datetime "created_at", :null => false
    t.datetime "updated_at", :null => false
  end

  create_table "people", :force => true do |t|
    t.integer "money_earned_total", :null => false, :default => 0
    t.integer "money_spent_total", :null => false, :default => 0
  end

  create_table "transactions", :force => true do |t|
    t.integer "person_id", :null => false
    t.integer "monetary_value", :null => false
  end

  create_table "soft_delete_paranoia", :force => true do |t|
    t.integer "company_id", :null => false
    t.integer "value", :default => 0
    t.timestamp "deleted_at"
  end

  create_table "soft_delete_discards", :force => true do |t|
    t.integer "company_id", :null => false
    t.integer "value", :default => 0
    t.timestamp "discarded_at"
  end

  #polymorphic
  create_table "poly_images", :force => true do |t|
    t.integer "imageable_id", :null => true
    t.string "imageable_type", :null => true
    t.string "imageable_uid", :null => true
    t.string "url"
  end

  create_table "poly_employees", :force => true do |t|
    t.string "name"
    t.string "uid"
    t.integer  "poly_images_count", :default => 0, :null => false
    t.integer  "poly_images_count_dup", :default => 0, :null => false
    t.integer  "poly_images_from_uids_count", :default => 0, :null => false
    t.integer  "special_poly_images_count", :default => 0, :null => false
  end

  create_table "poly_products", :primary_key => 'pp_pk_id', :force => true do |t|
    t.string "brand_name"
    t.string "uid"
    t.integer  "poly_images_count", :default => 0, :null => false
    t.integer  "poly_images_count_dup", :default => 0, :null => false
    t.integer  "poly_images_from_uids_count", :default => 0, :null => false
    t.integer  "special_poly_images_count", :default => 0, :null => false
  end

  create_table "conversations", :force => true do |t|
    t.integer "candidate_id"
  end

  create_table "candidates", :force => true do |t|
  end

  create_table "candidate_profiles", :force => true do |t|
    t.integer "candidate_id"
    t.integer "conversations_count", :default => 0, :null => false
  end

  create_table :versions, :force => true do |t|
    t.string   :item_type, limit: 191
    t.integer  :item_id,   null: false
    t.string   :event,     null: false
    t.integer  :whodunnit
    t.text    :object
    t.text    :object_changes
    t.datetime :created_at
  end
  add_index :versions, [:item_id, :item_type]

  create_table :with_module_model1s, :force => true do |t|
    t.integer :model2_id
  end

  create_table :with_module_model2s, :force => true do |t|
    t.integer :model1s_count
  end

  create_table :prefectures, :force => true do |t|
    t.string :name
    t.integer :big_cities_count, null: false, default: 0
    t.integer :small_cities_count, null: false, default: 0
  end

  create_table :cities, :force => true do |t|
    t.string :name
    t.integer :prefecture_id, null: false
    t.integer :population, null: false
  end

  create_table "groups", :force => true do |t|
    t.integer  "group_items_count", :default => 0, :null => false
  end

  create_table "sub_groups", primary_key: 'uuid', id: false, :force => true do |t|
    t.string  "uuid", :null => false
    t.integer  "group_id", :null => false
  end

  create_table "group_items", :force => true do |t|
    t.string  "sub_group_uuid", :null => false
  end

  create_table "article_groups", :force => true do |t|
    t.string  :name
    t.integer :articles_count, default: 0, null: false
  end

  create_table "articles", :force => true do |t|
    t.string  :title
    t.integer :article_group_id, :null => false
  end

  create_table "composite_groups", :force => true do |t|
    t.integer :secondary_id, :null => false
    t.integer :composite_users_count, :default => 0, :null => false
    t.integer :composite_users_pt_count, :default => 0, :null => false
  end

  create_table "composite_group_users", :force => true do |t|
    t.integer :composite_user_id, :null => false
    t.integer :composite_group_id, :null => false
    t.integer :secondary_id, :null => false
  end

  create_table "composite_users", :force => true do |t|
    t.integer :composite_groups_count, :default => 0, :null => false
  end

  if ENV['DB'] == 'postgresql' && ActiveRecord.version >= Gem::Version.new('5.0')
    create_table :purchase_orders, :force => true do |t|
      t.money "total_amount", scale: 2, default: "0.0", null: false
    end

    create_table :purchase_order_items, :force => true do |t|
      t.integer :purchase_order_id, null: false
      t.money "amount", scale: 2, default: "0.0", null: false
    end
  end

  create_table "sti_contracts", :force => true do |t|
    t.string   "type"
    t.string   "name"
    t.integer  "agreement_id"
    t.integer  "contracts_count", :default => 0, :null => false
    t.datetime "created_at"
    t.datetime "updated_at"
  end

  create_table "locking_parents", :force => true do |t|
    t.string   "name"
    t.integer  "children_count",      :default => 0, :null => false
    t.integer  "grandchildren_count", :default => 0, :null => false
    t.integer  "lock_version",        :default => 0, :null => false
    t.datetime "created_at"
    t.datetime "updated_at"
  end

  create_table "locking_children", :force => true do |t|
    t.integer  "locking_parent_id"
    t.integer  "grandchildren_count", :default => 0, :null => false
    t.datetime "created_at"
    t.datetime "updated_at"
  end

  create_table "locking_grandchildren", :force => true do |t|
    t.integer  "locking_child_id"
    t.datetime "created_at"
    t.datetime "updated_at"
  end

  create_table "reserved_word_parents", :force => true do |t|
    # `order` is a SQL reserved word in sqlite, mysql and postgres; storing the
    # counter cache here exercises identifier quoting when fix_counts writes it.
    t.integer  "order",       :default => 0, :null => false
    t.datetime "created_at"
    t.datetime "updated_at"
  end

  create_table "reserved_word_children", :force => true do |t|
    t.integer  "reserved_word_parent_id"
    t.datetime "created_at"
    t.datetime "updated_at"
  end
end
