20201102114643_create_promotions.rb 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # encoding:utf-8
  2. class CreatePromotions < ActiveRecord::Migration
  3. def up
  4. #促销表
  5. create_table :promotions do |t|
  6. # 促销名称
  7. t.column :name, :string,:limit => 128
  8. #开始时间
  9. t.column :begin_time,:datetime
  10. #结束时间
  11. t.column :end_time,:datetime
  12. # 是否首单
  13. t.column :is_first, :boolean, :default=>1
  14. # 多买多送
  15. t.column :is_more, :boolean, :default=>1
  16. # 最小金额
  17. t.column :min_total, :integer, :limit => 11, :default => 0
  18. # 最大金额
  19. t.column :max_total, :integer, :limit => 11, :default => 0
  20. # 买品1
  21. t.column :prod1, :integer, :limit => 11, :default => 0
  22. # 数量1
  23. t.column :nums1, :integer, :limit => 11, :default => 0
  24. # 买品2
  25. t.column :prod2, :integer, :limit => 11, :default => 0
  26. # 数量3
  27. t.column :nums2, :integer, :limit => 11, :default => 0
  28. # 买品3
  29. t.column :prod3, :integer, :limit => 11, :default => 0
  30. # 数量3
  31. t.column :nums3, :integer, :limit => 11, :default => 0
  32. # 赠品1
  33. t.column :send_prod1, :integer, :limit => 11, :default => 0
  34. # 数量1
  35. t.column :send_nums1, :integer, :limit => 11, :default => 0
  36. # 赠品2
  37. t.column :send_prod2, :integer, :limit => 11, :default => 0
  38. # 赠品数量2
  39. t.column :send_nums2, :integer, :limit => 11, :default => 0
  40. # 赠品3
  41. t.column :send_prod3, :integer, :limit => 11, :default => 0
  42. # 赠品数量3
  43. t.column :send_nums3, :integer, :limit => 11, :default => 0
  44. # 状态
  45. t.column :is_enable, :boolean, :default=>1
  46. t.timestamps
  47. end
  48. add_index :shop_applications, :user_id
  49. add_index :shop_applications, :wx_user_id
  50. add_index :promotions, :begin_time
  51. add_index :promotions, :end_time
  52. end
  53. def down
  54. remove_index :shop_applications, :user_id
  55. remove_index :shop_applications, :wx_user_id
  56. drop_table :promotions
  57. end
  58. end