import sqlite3

def init():
    conn = sqlite3.connect('eden_blackjack.db')
    cursor = conn.cursor()
    
    # Drop the old table so we can start fresh with the new columns
    cursor.execute('DROP TABLE IF EXISTS users')
    
    cursor.execute('''
        CREATE TABLE users (
            id INTEGER PRIMARY KEY AUTOINCREMENT,
            email TEXT UNIQUE NOT NULL,
            password_hash TEXT NOT NULL,
            nickname TEXT UNIQUE NOT NULL,  -- Keeps users from stealing active names!
            balance INTEGER DEFAULT 1000,
            peak_balance INTEGER DEFAULT 1000,
            two_factor_secret TEXT DEFAULT NULL,
            two_factor_enabled INTEGER DEFAULT 0
        )
    ''')
    
    conn.commit()
    conn.close()
    print("Database Updated: Added 2FA support (two_factor_secret, two_factor_enabled).")

if __name__ == "__main__":
    init()