20200504114641_create_carts.rb 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # encoding:utf-8
  2. class CreateCarts < ActiveRecord::Migration
  3. def up
  4. #购物车表
  5. create_table :carts do |t|
  6. # 会员ID
  7. t.column :user_id, :integer, :limit => 8, :default => 0
  8. # 微信ID
  9. t.column :wx_user_id, :integer, :limit => 8, :default => 0
  10. # 产品ID
  11. t.column :product_id, :integer, :limit => 8, :default => 0
  12. # 数量
  13. t.column :nums, :integer, :limit => 8, :default => 0
  14. # 是否购买
  15. t.column :is_buy, :boolean, :default=>1
  16. t.timestamps
  17. end
  18. #订单明细表
  19. create_table :order_details do |t|
  20. # 订单ID
  21. t.column :order_id, :integer, :limit => 8, :default => 0
  22. # 产品ID
  23. t.column :product_id, :integer, :limit => 8, :default => 0
  24. # 数量
  25. t.column :nums, :integer, :limit => 8, :default => 0
  26. # 价格
  27. t.column :price, :integer, :limit => 8, :default => 0
  28. # 产品名称
  29. t.column :product_name, :string,:limit => 500
  30. t.timestamps
  31. end
  32. end
  33. def down
  34. drop_table :carts
  35. end
  36. end