class CreatePurchaseDetails < ActiveRecord::Migration

  def self.up
    create_table "purchase_details", :force => true do |t|
      t.integer  "purchase_id",         :comment => '伝票番号'
      t.integer  "seq_number",          :comment => '枝番'
      t.string   "product_barcode",     :limit => 40, :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  "quantity",            :comment => '数量'
      t.integer  "scheduled_quantity",  :comment => '予定数'
      t.decimal  "price",               :precision => 16, :scale => 3, :comment => '価格'
      t.integer  "products_price_id",   :comment => '単価ID'
      #t.integer  "price",               :comment => '価格'
      t.column   "stock_type_code",     :"SMALLINT(6)", :comment => '在庫区分'
      t.column   "inspect_status_code", :"SMALLINT(6)", :comment => '検品状態'
      t.string   "detail_note",         :limit => 200, :comment => '備考'
      t.datetime "created_at",          :comment => '作成日時'
      t.datetime "updated_at",          :comment => '更新日時'
    end
    execute "ALTER TABLE purchase_details COMMENT = '仕入明細'"
    add_index "purchase_details", ["purchase_id"], :name => "purchase_id"
    add_index "purchase_details", ["product_set_id"], :name => "product_set_id"
    add_index "purchase_details", ["product_id"], :name => "product_id"
    add_index "purchase_details", ["stock_type_code"], :name => "stock_type_code"
  end

  def self.down
    drop_table :purchase_details
  end

end
