class CreateProductsStocks < ActiveRecord::Migration

  def self.up
    create_table "products_stocks", :force => true do |t|
      t.integer  "supplier_id",               :comment => '在庫主'
      t.column   "target_year",               :"SMALLINT(4)", :comment => '対象年'
      t.column   "target_month",              :"TINYINT(2)",  :comment => '対象月'
      t.integer  "product_category_id",       :comment => '製品カテゴリ'
      t.integer  "product_set_id",            :comment => '製品名'
      t.integer  "product_id",                :comment => '製品モデル'
      t.integer  "own_purchase_quantity",     :comment => '月間自社倉庫仕入本数'
      t.integer  "other_purchase_quantity",   :comment => '月間貸出倉庫仕入本数'
      t.integer  "own_sale_quantity",         :comment => '月間自社倉庫売上本数'
      t.integer  "other_sale_quantity",       :comment => '月間貸出倉庫売上本数'
      t.integer  "shipping_quantity",         :comment => '月間出荷本数'
      t.integer  "restoration_quantity",      :comment => '月間返却本数'
      t.integer  "disposal_quantity",         :comment => '月間廃棄本数'
      t.integer  "sample_quantity",           :comment => '月間サンプル本数'
      t.integer  "adjustment_quantity",       :comment => '月間在庫調整本数'
      t.integer  "own_previous_quantity",     :comment => '前月末自社在庫数'
      t.integer  "other_previous_quantity",   :comment => '前月末貸出在庫数'
      t.integer  "own_current_quantity",      :comment => '当月末自社在庫数'
      t.integer  "other_current_quantity",    :comment => '当月末貸出在庫数'
      t.integer  "products_price_id",         :comment => '単価ID'
      t.datetime "created_at",                :comment => '作成日時'
      t.datetime "updated_at",                :comment => '更新日時'
    end
    add_index "products_stocks", ["target_year"],    :name => "target_year"
    add_index "products_stocks", ["target_month"],   :name => "target_month"
    add_index "products_stocks", ["supplier_id"],    :name => "supplier_id"
    add_index "products_stocks", ["product_set_id"], :name => "product_set_id"
    add_index "products_stocks", ["product_id"],     :name => "product_id"
    add_index "products_stocks", ["products_price_id"], :name => "products_price_id"
  end

  def self.down
    drop_table :products_stocks
  end

end
