JhHardwareWRS_BackPoint/scripts/migrate_continuous_die_changeover_count.py
2026-06-24 15:19:14 +08:00

34 lines
919 B
Python

from sqlalchemy import text
from app.database import engine
def main() -> None:
with engine.begin() as conn:
exists = conn.execute(
text(
"""
SELECT COUNT(*)
FROM information_schema.columns
WHERE table_schema = DATABASE()
AND table_name = 'production_report_items'
AND column_name = 'changeover_count'
"""
)
).scalar()
if not exists:
conn.execute(
text(
"""
ALTER TABLE production_report_items
ADD COLUMN changeover_count DECIMAL(12, 2) NOT NULL DEFAULT 0
AFTER process_unit_price_yuan
"""
)
)
print("migrate_continuous_die_changeover_count done")
if __name__ == "__main__":
main()