class CreateStocks < ActiveRecord::Migration

  def self.up
    create_table "stocks", :force => true do |t|
      t.integer  "customer_id",               :comment => '得意先'
      t.integer  "warehouse_id",              :comment => '納品先'
      t.integer  "supplier_id",               :comment => '在庫主'
      t.integer  "product_category_id",       :comment => '製品カテゴリ'
      t.integer  "product_set_id",            :comment => '製品名'
      t.integer  "product_id",                :comment => '製品モデル'
      t.string   "lot_number",                :limit => 20, :comment => 'ロット'
      t.string   "serial_number",             :limit => 40, :comment => 'シリアル'
      t.date     "ubd",                       :comment => 'UBD'
      t.integer  "validity_period",           :comment => '有効期間'
      t.column   "unit_code",                 :"SMALLINT(6)", :comment => '単位'
      t.integer  "existing_quantity",         :comment => '実在庫数'
      t.integer  "available_quantity",        :comment => '有効在庫数'
      t.integer  "short_shipped_quantity",    :comment => '短期分庫数'
      t.integer  "price",                     :comment => '在庫単価'
      t.integer  "total_price",               :comment => '在庫金額'
      t.datetime "created_at",                :comment => '作成日時'
      t.datetime "updated_at",                :comment => '更新日時'
    end
    execute "ALTER TABLE stocks COMMENT = '在庫'"
    add_index "stocks", ["customer_id"], :name => "customer_id"
    add_index "stocks", ["warehouse_id"], :name => "warehouse_id"
    add_index "stocks", ["supplier_id"], :name => "supplier_id"
    add_index "stocks", ["product_set_id"], :name => "product_set_id"
    add_index "stocks", ["product_id"], :name => "product_id"
  end

  def self.down
    drop_table :stocks
  end

end
