import db

queries = [
    "ALTER TABLE orders ADD COLUMN material_name VARCHAR(100) NULL",
    "ALTER TABLE orders ADD COLUMN material_price DECIMAL(10,4) DEFAULT NULL",
    "ALTER TABLE orders ADD COLUMN quantity INT DEFAULT 1",
    "ALTER TABLE orders ADD COLUMN notes TEXT",
    "ALTER TABLE orders ADD COLUMN allow_portfolio BOOLEAN DEFAULT FALSE",
    "ALTER TABLE orders ADD COLUMN estimated_price DECIMAL(10,2) DEFAULT NULL",
]

for q in queries:
    try:
        db.execute_commit(q)
        col = q.split("ADD COLUMN ")[1].split(" ")[0]
        print(f"  + {col} added")
    except Exception as e:
        if "Duplicate column" in str(e):
            col = q.split("ADD COLUMN ")[1].split(" ")[0]
            print(f"  ~ {col} already exists")
        else:
            print(f"  ! Error: {e}")
