from datetime import datetime from sqlalchemy import Index, String from sqlalchemy.orm import Mapped, mapped_column from app.models.base import Base, UTCDateTime, utcnow class LoginAttempt(Base): __tablename__ = "login_attempts" __table_args__ = ( Index("ix_login_attempts_username_time", "username", "attempted_at"), Index("ix_login_attempts_ip_time", "ip", "attempted_at"), ) id: Mapped[int] = mapped_column(primary_key=True) username: Mapped[str] = mapped_column(String(255)) ip: Mapped[str | None] = mapped_column(String(45)) attempted_at: Mapped[datetime] = mapped_column(UTCDateTime, default=utcnow) success: Mapped[bool]