# encoding:utf-8
class CreateOrderStatics < ActiveRecord::Migration
  def up
    #创建商品销售汇总
    create_table :order_statics do |t|
      #开始时间
      t.column :begin_date,:datetime
      #结束时间
      t.column :end_date,:datetime
      #订单状态
      t.column :state, :string,:limit => 256
      # 是否赠品
      t.column :is_send, :boolean, :default=>1
      t.timestamps
    end

    #创建商品销售汇总明细
    create_table :order_static_details do |t|
      #开始时间
      t.column :begin_date,:datetime
      #结束时间
      t.column :end_date,:datetime
      #订单状态
      t.column :state, :string,:limit => 256
      # 是否赠品
      t.column :is_send, :boolean, :default=>1
      # 产品ID
      t.column :product_id, :integer, :limit => 8, :default => 0
      # 汇总ID
      t.column :static_id, :integer, :limit => 8, :default => 0
      # 商品名称
      t.column :product_name, :string,:limit => 256
      # 数量
      t.column :nums, :integer, :limit => 8, :default => 0
      # 总金额
      t.column :total, :integer, :limit => 11, :default => 0
      t.timestamps
    end
  end

  def down
  	drop_table :order_statics
    drop_table :order_static_details
  end

end
