from pathlib import Path import sys from sqlalchemy import text ROOT = Path(__file__).resolve().parents[1] sys.path.insert(0, str(ROOT)) from app.database import engine # noqa: E402 def main() -> None: with engine.begin() as conn: exists = conn.execute(text(""" SELECT COUNT(1) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'production_report_items' AND column_name = 'raw_material_batch_no' """)).scalar() if not exists: conn.execute(text(""" ALTER TABLE production_report_items ADD COLUMN raw_material_batch_no VARCHAR(128) NULL AFTER material_name """)) print("report item raw material batch migrated") if __name__ == "__main__": main()