from sqlalchemy import text
from database import engine, create_db_and_tables
from sqlmodel import Session, select
from models import User
from routers.auth import get_password_hash

def reset_and_seed():
    with engine.connect() as conn:
        conn.execute(text("DROP TABLE IF EXISTS users CASCADE"))
        conn.commit()
        print("Dropped old users table.")
    
    create_db_and_tables()
    
    with Session(engine) as session:
        user = User(
            username="Mediatroy@gmail.com",
            email="mediatroy@gmail.com",
            full_name="Media Troy",
            hashed_password=get_password_hash("password123")
        )
        session.add(user)
        session.commit()
        print("✅ Account 'Mediatroy@gmail.com' created with password 'password123'")

if __name__ == "__main__":
    reset_and_seed()
