class CreateOrderDetails < ActiveRecord::Migration

  def self.up
    create_table "order_details", :force => true do |t|
      t.integer  "order_id",            :comment => '伝票番号'
      t.integer  "seq_number",          :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.decimal  "price",               :precision => 16, :scale => 3, :comment => '価格'
      
      t.column   "stock_type_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 order_details COMMENT = '発注明細'"
    add_index "order_details", ["order_id"], :name => "order_id"
    add_index "order_details", ["product_set_id"], :name => "product_set_id"
    add_index "order_details", ["product_id"], :name => "product_id"
    add_index "order_details", ["stock_type_code"], :name => "stock_type_code"
  end

  def self.down
    drop_table :order_details
  end

end
