import sys
import os
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))

import sqlite3
from web.config import Config

conn = sqlite3.connect(Config.DB_L2_PATH)
cursor = conn.cursor()

columns = [
    'util_flash_usage',
    'util_smoke_usage',
    'util_molotov_usage',
    'util_he_usage',
    'util_decoy_usage'
]

for col in columns:
    try:
        cursor.execute(f"ALTER TABLE fact_match_players ADD COLUMN {col} INTEGER DEFAULT 0")
        print(f"Added column {col}")
    except sqlite3.OperationalError as e:
        if "duplicate column name" in str(e):
            print(f"Column {col} already exists.")
        else:
            print(f"Error adding {col}: {e}")

conn.commit()
conn.close()
