# modules/auth/models.py
from core.database import Base
from sqlalchemy import Column, Integer, String, Enum, DateTime, Text
from sqlalchemy.orm import relationship
from enum import Enum as PyEnum


class UserRole(str, PyEnum):
    ADMIN = "admin"
    USER = "user"


class User(Base):
    __tablename__ = "users"
    id = Column(Integer, primary_key=True)
    uuid = Column(String, unique=True)
    username = Column(String, unique=True)
    name = Column(String)
    role = Column(Enum(UserRole), nullable=False, default=UserRole.USER)
    hashed_password = Column(String)
    expo_push_token = Column(Text, nullable=True)
    calendar_events = relationship("CalendarEvent", back_populates="user")


class TokenBlacklist(Base):
    __tablename__ = "token_blacklist"

    id = Column(Integer, primary_key=True)
    token = Column(String, unique=True)
    expires_at = Column(DateTime)
