alter_db_warehouse_units.py 668 B

123456789101112131415161718192021
  1. import db
  2. def migrate():
  3. print("Migrating warehouse_stock table to support units and mass...")
  4. # Add unit_mass and units_count columns
  5. queries = [
  6. "ALTER TABLE warehouse_stock ADD COLUMN unit_mass decimal(10,3) DEFAULT 1.000",
  7. "ALTER TABLE warehouse_stock ADD COLUMN units_count int DEFAULT 0",
  8. # Optionally update quantity to be units_count * unit_mass?
  9. # For now, let's just add them.
  10. ]
  11. for q in queries:
  12. try:
  13. db.execute_commit(q)
  14. print(f"Executed: {q}")
  15. except Exception as e:
  16. print(f"Error executing {q}: {e}")
  17. if __name__ == "__main__":
  18. migrate()