20161103040139_create_wx_events.rb 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. class CreateWxEvents < ActiveRecord::Migration
  2. def self.up
  3. create_table :wx_events do |t|
  4. #微信公众号
  5. t.integer :wx_gongzhonghao_id, :null => false
  6. # 回复类型,图文,文本
  7. t.column :return_type, "ENUM('item', 'text') NOT NULL"
  8. # 发送的关键字
  9. t.string :key
  10. # 回复图文时的图文列表rootId
  11. t.integer :wx_event_item_id
  12. t.text :return_text_content
  13. t.column :state, :boolean, :default => false
  14. t.timestamps
  15. end
  16. add_index :wx_events, :wx_gongzhonghao_id
  17. add_index :wx_events, :key
  18. create_table :wx_event_items do |t|
  19. #微信公众号
  20. t.integer :article_id, :null => false
  21. #树状名称
  22. t.column :name, :string, :null => false, :limit => 100
  23. #新标题,否则就用article的title
  24. t.column :title, :string
  25. #是否启用新标题
  26. t.column :use_title, :boolean, :default => false
  27. #新封面,否则就用article的封面
  28. t.column :cover, :string
  29. #是否启用新封面
  30. t.column :use_cover, :boolean, :default => false
  31. #新点击链接,否则就是article的详情页
  32. t.column :href, :string
  33. #是否启用新链接
  34. t.column :use_href, :boolean, :default => false
  35. t.column :position, :integer
  36. t.column :click_times, :integer
  37. t.column :ancestry, :string, :limit => 100
  38. #是否启用
  39. t.column :state, :boolean, :default => false
  40. end
  41. add_index :wx_event_items, :ancestry
  42. end
  43. def self.down
  44. drop_table :wx_events
  45. drop_table :wx_event_items
  46. end
  47. end