20180908023758_create_push_tmpl.rb 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. class CreatePushTmpl < ActiveRecord::Migration
  2. def self.up
  3. create_table :push_tmpls do |t|
  4. # 这里单独可填微信用户id(以逗号分隔)、填all(所有微信用户)、填allUser(所有注册用户)、填sql=xxx(xxx执行结果是WxUserGongzhonghao结构体)
  5. t.column :user_id, :text
  6. #模板类型
  7. t.column :msg_type, :string
  8. #强制推送
  9. t.column :push_force, :boolean, :default=>false
  10. #推送人数
  11. t.column :push_count, :integer, :default => 0
  12. #点击人数
  13. t.column :click_count, :integer, :default => 0
  14. #标题
  15. t.column :first, :string
  16. #内容1
  17. t.column :keyword1, :string
  18. t.column :keyword2, :string
  19. t.column :keyword3, :string
  20. t.column :keyword4, :string
  21. #内容5
  22. t.column :keyword5, :string
  23. #备注
  24. t.column :remark, :string
  25. #点击链接
  26. t.column :url, :string
  27. #推送次数
  28. t.column :times, :integer, :default => 0
  29. # 最后一次发送时间
  30. t.column :last_updated_at, :datetime
  31. #公众号
  32. t.column :wx_gongzhonghao_id, :integer, :default => 1
  33. t.timestamps
  34. end
  35. create_table :push_tmpl_records do |t|
  36. t.column :wx_uid, :integer, :null=>false
  37. t.column :push_time, :datetime, :null=>false
  38. t.column :temp_id, :integer, :null=>false
  39. end
  40. add_index :push_tmpl_records, :wx_uid
  41. end
  42. def self.down
  43. drop_table :push_tmpls
  44. drop_table :push_tmpl_records
  45. end
  46. end