20210415114688_create_product_warns.rb 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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,:datetime
  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. # 近90日销售
  13. t.column :sale_90, :integer, :limit => 11, :null => false, :default => 0
  14. # 近30日销售
  15. t.column :sale_30, :integer, :limit => 11, :null => false, :default => 0
  16. # 近10日销售
  17. t.column :sale_10, :integer, :limit => 11, :null => false, :default => 0
  18. # 现有库存数
  19. t.column :now_count, :integer, :limit => 11, :null => false, :default => 0
  20. # 生产周期
  21. t.column :product_cycle, :integer, :limit => 11, :null => false, :default => 0
  22. # 备货周期
  23. t.column :stock_cycle, :integer, :limit => 11, :null => false, :default => 0
  24. # 最低进货量
  25. t.column :min_purchase, :integer, :limit => 11, :null => false, :default => 0
  26. # 历史日均销量
  27. t.column :history_day_sales, :integer, :limit => 11, :null => false, :default => 0
  28. # 建议生产数
  29. t.column :recommend_count, :integer, :limit => 11, :null => false, :default => 0
  30. t.timestamps
  31. end
  32. add_column :products, :product_cycle, :integer, :limit => 11, :null => false, :default => 0
  33. add_column :products, :stock_cycle, :integer, :limit => 11, :null => false, :default => 0
  34. add_column :products, :min_purchase, :integer, :limit => 11, :null => false, :default => 0
  35. end
  36. def down
  37. drop_table :product_warns
  38. end
  39. end