20161017200006_create_channel_qrcodes.rb 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # encoding:utf-8
  2. class CreateChannelQrcodes < ActiveRecord::Migration
  3. def self.up
  4. create_table :channel_qrcodes do |t|
  5. t.column :wx_gongzhonghao_id, :integer, :null => false
  6. #相关注册渠道
  7. t.column :parent_sign_up_channel_id, :integer
  8. t.column :scene_id, :integer, :default => 0
  9. #场景字符串
  10. t.column :scene_str, :string, :limit=>64
  11. # 是否永久
  12. t.boolean :is_permanent, :default => false
  13. # 描述
  14. t.column :remark, :text, :null => false
  15. # 二维码图片地址
  16. t.column :qrcode_img, :text #有效期
  17. t.column :expired_at, :datetime
  18. #被扫了多少次
  19. t.column :scan_times, :integer, :default => 0
  20. # 扫描后的推送
  21. t.column :push_after_sub_id, :integer, :default => 0
  22. #渠道外链-增加客服wx_id
  23. # t.column :cs_wx_uid, :integer, :default=>0
  24. #邀请人wx_id
  25. # t.column :invite_wx_uid, :integer, :default=>0
  26. t.timestamps
  27. end
  28. add_index :channel_qrcodes, :expired_at
  29. create_table :channel_qrcode_results do |t|
  30. t.column :mp_openid, :string, :default => 0
  31. t.column :channel_qrcode_id, :integer
  32. t.timestamps
  33. end
  34. add_index :channel_qrcode_results, :mp_openid
  35. add_index :channel_qrcode_results, :channel_qrcode_id
  36. add_index :channel_qrcode_results, [:mp_openid,:channel_qrcode_id], :unique => true, :name=>"idx_cq_result_openid_and_cq_id"
  37. end
  38. def self.down
  39. drop_table :channel_qrcodes
  40. drop_table :channel_qrcode_results
  41. end
  42. end