class CreateShareInfo < ActiveRecord::Migration
  def change
    create_table :share_infos do |t|
       #分享活动类型：商品销售专题、商品详情页
       t.string   :share_code,  :null => false
       #关联ID
       t.string   :relate_id,  :null => false
       #关联ID的相关，如活动订单的分享，这个字段可以存活动ID
       t.string   :relate_parent,  :null => false
       #用户ID
       t.integer  :wx_user_id,  :default => 0
       #分享朋友圈，还是朋友group,timeline
       t.string  :share_to,  :null => false, :limit => 20
       #IP
       t.string   :ip,  :null => false

       #分享次数
       t.integer :share_times, :default => 0
       #最新分享时间
       t.datetime  :share_latest_time

       t.timestamps
    end
    add_index :share_infos, :relate_id
    add_index :share_infos, :share_code
    add_index :share_infos, :relate_parent
  end
  def down
    drop_table :share_infos
  end
end
