import db

def migrate():
    print("Migrating warehouse_stock table to support units and mass...")
    # Add unit_mass and units_count columns
    queries = [
        "ALTER TABLE warehouse_stock ADD COLUMN unit_mass decimal(10,3) DEFAULT 1.000",
        "ALTER TABLE warehouse_stock ADD COLUMN units_count int DEFAULT 0",
        # Optionally update quantity to be units_count * unit_mass? 
        # For now, let's just add them.
    ]
    
    for q in queries:
        try:
            db.execute_commit(q)
            print(f"Executed: {q}")
        except Exception as e:
            print(f"Error executing {q}: {e}")

if __name__ == "__main__":
    migrate()
