import sqlite3

con = sqlite3.connect("db/memos.db")
cur = con.execute("SELECT name FROM sqlite_master WHERE type='table'")
tables = [r[0] for r in cur.fetchall()]
print("Tables:", tables)

# Check if cuccu_refresh_tokens exists
if "cuccu_refresh_tokens" not in tables:
    print("MISSING: cuccu_refresh_tokens - creating...")
    con.execute("""
        CREATE TABLE IF NOT EXISTS cuccu_refresh_tokens (
            id INTEGER PRIMARY KEY AUTOINCREMENT,
            user_id TEXT NOT NULL,
            token TEXT NOT NULL,
            expires_at TEXT,
            created_at TEXT
        )
    """)
    con.commit()
    print("Created cuccu_refresh_tokens OK")
else:
    print("OK: cuccu_refresh_tokens exists")

con.close()
