import mysql.connector
from db import DB_CONFIG

def add_ua_columns():
    try:
        conn = mysql.connector.connect(**DB_CONFIG)
        cursor = conn.cursor()
        
        queries = [
            "ALTER TABLE materials ADD COLUMN name_ua VARCHAR(100) DEFAULT NULL AFTER name_ru",
            "ALTER TABLE materials ADD COLUMN desc_ua TEXT DEFAULT NULL AFTER desc_ru",
            "ALTER TABLE services ADD COLUMN name_ua VARCHAR(100) DEFAULT NULL AFTER name_ru",
            "ALTER TABLE services ADD COLUMN desc_ua TEXT DEFAULT NULL AFTER desc_ru"
        ]
        
        for q in queries:
            try:
                cursor.execute(q)
                print(f"Executed: {q}")
            except mysql.connector.Error as e:
                print(f"Error executing {q}: {e}")
                
        conn.commit()
        print("UA columns added successfully")
        
    except mysql.connector.Error as err:
        print(f"Connection error: {err}")
    finally:
        if 'conn' in locals() and conn.is_connected():
            cursor.close()
            conn.close()

if __name__ == "__main__":
    add_ua_columns()
