from sqlalchemy import Column, Integer, String, Boolean, DateTime, Text, Date
from sqlalchemy.sql import func
from app.db.base import Base

class User(Base):
    __tablename__ = "users"
    __table_args__ = {"schema": "data"}

    id = Column(Integer, primary_key=True, index=True)
    email = Column(String, unique=True, index=True, nullable=False)
    password_hash = Column(Text, nullable=False)
    full_name = Column(String, nullable=True)
    
    # --- Social / Trust Fields ---
    is_active = Column(Boolean, default=True)
    is_superuser = Column(Boolean, default=False)
    reputation_score = Column(Integer, default=0)

    # --- Document Tracking (ÚJ MEZŐK) ---
    license_expiry_date = Column(Date, nullable=True)   # Jogosítvány lejárata
    id_card_expiry_date = Column(Date, nullable=True)   # Személyi igazolvány lejárata
    # ------------------------------------
    
    created_at = Column(DateTime(timezone=True), server_default=func.now())
    updated_at = Column(DateTime(timezone=True), onupdate=func.now())