dy-dashboard/scripts/migrate_spot_sales_inbound.py
2026-10-28 11:14:17 +08:00

26 lines
731 B
Python

"""Add a nullable manual override; NULL preserves domestic completion sourcing."""
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
if '--local' in sys.argv:
import test_wsgi
from services.db import get_db
def migrate():
conn = get_db()
try:
with conn.cursor() as cur:
cur.execute('SHOW COLUMNS FROM products LIKE %s', ('spot_first_inbound_override',))
if not cur.fetchone():
cur.execute('ALTER TABLE products ADD COLUMN spot_first_inbound_override DATE NULL')
conn.commit()
print('products.spot_first_inbound_override ready')
finally:
conn.close()
if __name__ == '__main__':
migrate()