#!/usr/bin/env python3 # -*- coding: utf-8 -*- import os import sys sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from app.database import get_connection, MARIADB_NAME sys.stdout.reconfigure(encoding='utf-8') conn = get_connection() cur = conn.cursor() cur.execute(""" SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = %s AND TABLE_NAME = 'recipes' AND COLUMN_NAME = 'subtitle' """, (MARIADB_NAME,)) if not cur.fetchone(): cur.execute("ALTER TABLE recipes ADD COLUMN subtitle VARCHAR(255) DEFAULT '' AFTER title") print("Column 'subtitle' added to MariaDB 'recipes' table.") else: print("Column 'subtitle' already exists in MariaDB 'recipes' table.") cur.execute("DESCRIBE recipes") for col in cur.fetchall(): print(f" {col['Field']}: {col['Type']}") conn.close()