class CreateShippings < ActiveRecord::Migration

  def self.up
    create_table "shippings", :force => true do |t|
      t.integer  "accept_order_id",          :comment => '受注番号'
      t.integer  "shipping_order_id",        :comment => '出荷指示番号'
      t.integer  "rev_number",               :comment => 'リビジョン番号'
      t.date     "input_date",               :comment => '入力日'
      t.date     "target_date",              :comment => '処理日'
      t.integer  "user_id",                  :comment => '入力者'
      t.integer  "section_id",               :comment => '入力者部署'
      t.column   "shipping_trigger_code",    :"SMALLINT(6)", :comment => '出荷要因'
      t.integer  "supplier_id",              :comment => '出荷元'
      t.integer  "own_warehouse_id",         :comment => '倉庫'
      t.integer  "warehouse_id",             :comment => '納品先'
      t.integer  "user_position_id",         :comment => '営業担当者'
      t.integer  "sales_user_id",            :comment => '担当者'
      t.integer  "sales_area_id",            :comment => '営業エリア'
      t.integer  "sales_section_id",         :comment => '営業部署'
      t.integer  "customer_id",              :comment => '得意先'
      t.integer  "shipment_customer_id",     :comment => '配送先'
      t.integer  "delivery_id",              :comment => '営業店止'
      t.integer  "trucking_id",              :comment => '配送業者'
      t.string   "receiver_name",            :limit => 20, :comment => '受取人'
      t.string   "request_time",             :limit => 20, :comment => '時間指定'
      t.column   "shipping_sheet_type_code", :"SMALLINT(6)", :comment => '伝票形式'
      t.column   "shipping_state_code",      :"SMALLINT(6)", :comment => '状態'
      t.column   "shipping_type_code",   :"SMALLINT(6)", :comment => '出荷区分'
      t.column   "original_shipping_type_code",   :"SMALLINT(6)", :comment => '受注元出荷区分'
      t.string   "customer_order_number",     :limit => 40, :comment => '注文番号'
      t.integer  "total_quantity",            :comment => '総数'
      t.string   "note",                     :limit => 200, :comment => '備考'
      t.string   "shipping_note",            :limit => 200, :comment => '伝票備考'
      t.string   "message_note",             :limit => 200, :comment => '連絡事項'
      t.datetime "print_picking_date",       :comment => 'ピッキングリスト印刷日時'
      t.datetime "print_sheet_date",         :comment => '伝票印刷日時'
      t.column   "invalid_flag_code",        :"SMALLINT(6)", :comment => '削除フラグ'
      t.datetime "deleted_at",               :comment => '削除日時'
      t.datetime "created_at",               :comment => '作成日時'
      t.datetime "updated_at",               :comment => '更新日時'
    end
    execute "ALTER TABLE shippings COMMENT = '出荷'"
    add_index 'shippings', ['accept_order_id'], :name => 'accept_order_id'
    add_index 'shippings', ['target_date'], :name => 'target_date'
    add_index 'shippings', ['supplier_id'], :name => 'supplier_id'
    add_index 'shippings', ['warehouse_id'], :name => 'warehouse_id'
    add_index 'shippings', ['user_position_id'], :name => 'user_position_id'
    add_index 'shippings', ['sales_user_id'], :name => 'sales_user_id'
    add_index 'shippings', ['sales_area_id'], :name => 'sales_area_id'
    add_index 'shippings', ['sales_section_id'], :name => 'sales_section_id'
    add_index 'shippings', ['customer_id'], :name => 'customer_id'
    add_index "shippings", ["shipping_type_code"], :name => "shipping_type_code"
  end

  def self.down
    drop_table :shippings
  end

end
