# encoding:utf-8
class CreateProductCommends < ActiveRecord::Migration
  def up
    #商品评论管理
    create_table :product_commends do |t|
      #微信ID
      t.column :wx_user_id, :integer,:null=>false, :default => 0
      #商品ID
      t.column :product_id, :integer,:null=>false, :default => 0
      #订单号
      t.column :order_id, :string,:limit => 256
      # 文字
      t.column :detail, :string,:limit => 256
      #评分
      t.column :score, :integer,:null=>false, :default => 0
      # 状态
      t.column :is_enable, :boolean, :default=>false
      # 是否置顶
      t.column :is_top, :boolean, :default=>false
      # 推荐程度
      t.column :recommend, :integer,:null=>false, :default => 0
      # 备注
      t.column :remark, :string,:limit => 256
      t.timestamps
    end

    #单牛记录表
    create_table :d5c_project_traces do |t|
      #项目id
      t.column :project_id, :integer, :null => false, :default=>0
      # 同步追溯ID
      t.column :sync_record_id, :integer, :default=>0
      #所在棚栏
      t.column :location, :string, :limit => 100
      #头图
      t.column :img_head, :string, :limit => 255
      #图片一
      t.column :img_one, :string, :limit => 255
      #图片二
      t.column :img_two, :string, :limit => 255
      #视频链接
      t.column :url, :string, :limit => 200
      #记录内容
      t.column :about, :string, :limit => 500
      #上件文件
      t.column :up_file, :string, :limit => 255
      #状态：0项目成功，1采购中，2入栏
      t.column :state, :tinyint, :limit => 4, :default => 0
      #用户id
      t.column :user_id, :integer, :null => false, :default=>0
      # 排序
      t.column :sort, :integer, :default=>0
      #是否显示：0否，1是
      t.column :audit, :boolean, :default => true
      #编辑人
      t.column :editor, :string, :limit => 100
      #时间戳
      t.timestamps
    end

    add_index :product_commends, :wx_user_id
    add_index :product_commends, :product_id
    add_column :order_details, :commend, :boolean, :default=>false

  end

  def down
  	drop_table :product_commends
  end
end


