migrate_dimensions.py 711 B

1234567891011121314151617181920
  1. import db
  2. def migrate():
  3. print("Migrating database to add dimensions column to order_files...")
  4. try:
  5. # Check if column exists first using MySQL syntax
  6. columns = db.execute_query("SHOW COLUMNS FROM order_files")
  7. column_names = [c['Field'] for c in columns]
  8. if 'dimensions' not in column_names:
  9. db.execute_commit("ALTER TABLE order_files ADD COLUMN dimensions VARCHAR(255)")
  10. print("Successfully added 'dimensions' column to 'order_files' table.")
  11. else:
  12. print("Column 'dimensions' already exists.")
  13. except Exception as e:
  14. print(f"Migration error: {e}")
  15. if __name__ == "__main__":
  16. migrate()