20210415114688_create_product_warns.rb 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # encoding:utf-8
  2. class CreateProductWarns < ActiveRecord::Migration
  3. def up
  4. #商品生产预警
  5. create_table :product_warns do |t|
  6. # 统计时间
  7. t.column :happen_time,:date
  8. # 商品ID
  9. t.column :product_id, :integer, :limit => 4, :null => false, :default => 0
  10. # 商品名称
  11. t.column :product_name, :string, :limit => 128, :null => false,:default => ""
  12. # 商品类型
  13. t.column :product_type, :string, :limit => 128, :null => false,:default => ""
  14. # 商品规格
  15. t.column :product_size, :string, :limit => 128, :null => false,:default => ""
  16. # 近90日销售
  17. t.column :sale_90, :integer, :limit => 11, :null => false, :default => 0
  18. # 近30日销售
  19. t.column :sale_30, :integer, :limit => 11, :null => false, :default => 0
  20. # 近10日销售
  21. t.column :sale_10, :integer, :limit => 11, :null => false, :default => 0
  22. # 现有库存数
  23. t.column :now_count, :integer, :limit => 11, :null => false, :default => 0
  24. # 生产周期
  25. t.column :product_cycle, :integer, :limit => 11, :null => false, :default => 0
  26. # 备货周期
  27. t.column :stock_cycle, :integer, :limit => 11, :null => false, :default => 0
  28. # 最低进货量
  29. t.column :min_purchase, :integer, :limit => 11, :null => false, :default => 0
  30. # 历史日均销量
  31. t.column :history_day_sales, :integer, :limit => 11, :null => false, :default => 0
  32. # 建议生产数
  33. t.column :recommend_count, :integer, :limit => 11, :null => false, :default => 0
  34. t.timestamps
  35. end
  36. add_column :products, :product_cycle, :integer, :limit => 11, :null => false, :default => 0
  37. add_column :products, :stock_cycle, :integer, :limit => 11, :null => false, :default => 0
  38. add_column :products, :min_purchase, :integer, :limit => 11, :null => false, :default => 0
  39. end
  40. def down
  41. drop_table :product_warns
  42. end
  43. end