"""
Run once from the backend folder:
    python add_icon_class_column.py
"""
import sqlite3, os

db = os.path.join(os.path.dirname(__file__), 'db.sqlite3')
conn = sqlite3.connect(db)
cur = conn.cursor()

# Check if column already exists
cur.execute("PRAGMA table_info(pages_servicecategory)")
cols = [row[1] for row in cur.fetchall()]

if 'icon_class' in cols:
    print('Column already exists — nothing to do.')
else:
    cur.execute("ALTER TABLE pages_servicecategory ADD COLUMN icon_class VARCHAR(100) NOT NULL DEFAULT ''")
    conn.commit()
    print('Done — icon_class column added to pages_servicecategory.')

conn.close()
