22 lines
716 B
Python
22 lines
716 B
Python
from datetime import datetime
|
|
|
|
from sqlalchemy import Boolean, DateTime, String, func
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from app.database import Base
|
|
|
|
|
|
class LoginAttempt(Base):
|
|
__tablename__ = "login_attempts"
|
|
|
|
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
|
|
ip_address: Mapped[str] = mapped_column(String(64), nullable=False, index=True)
|
|
username: Mapped[str | None] = mapped_column(String(64), nullable=True)
|
|
success: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False)
|
|
created_at: Mapped[datetime] = mapped_column(
|
|
DateTime(timezone=True),
|
|
server_default=func.now(),
|
|
nullable=False,
|
|
index=True,
|
|
)
|