20201102114643_create_promotions.rb 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 :order_type, :integer, :limit => 11, :default => 0
  18. # 最小金额
  19. t.column :min_total, :integer, :limit => 11, :default => 0
  20. # 最大金额
  21. t.column :max_total, :integer, :limit => 11, :default => 0
  22. # 买品1
  23. t.column :prod1, :integer, :limit => 11, :default => 0
  24. # 数量1
  25. t.column :nums1, :integer, :limit => 11, :default => 0
  26. # 买品2
  27. t.column :prod2, :integer, :limit => 11, :default => 0
  28. # 数量3
  29. t.column :nums2, :integer, :limit => 11, :default => 0
  30. # 买品3
  31. t.column :prod3, :integer, :limit => 11, :default => 0
  32. # 数量3
  33. t.column :nums3, :integer, :limit => 11, :default => 0
  34. # 赠品1
  35. t.column :send_prod1, :integer, :limit => 11, :default => 0
  36. # 数量1
  37. t.column :send_nums1, :integer, :limit => 11, :default => 0
  38. # 赠品2
  39. t.column :send_prod2, :integer, :limit => 11, :default => 0
  40. # 赠品数量2
  41. t.column :send_nums2, :integer, :limit => 11, :default => 0
  42. # 赠品3
  43. t.column :send_prod3, :integer, :limit => 11, :default => 0
  44. # 赠品数量3
  45. t.column :send_nums3, :integer, :limit => 11, :default => 0
  46. # 状态
  47. t.column :is_enable, :boolean, :default=>1
  48. t.timestamps
  49. end
  50. add_index :shop_applications, :user_id
  51. add_index :shop_applications, :wx_user_id
  52. add_index :promotions, :begin_time
  53. add_index :promotions, :end_time
  54. end
  55. def down
  56. remove_index :shop_applications, :user_id
  57. remove_index :shop_applications, :wx_user_id
  58. drop_table :promotions
  59. end
  60. end