""" Auth 모듈 SQLAlchemy 모델 정의 카카오 로그인 사용자 정보를 저장합니다. """ from datetime import datetime from sqlalchemy import DateTime, Index, Integer, String, func from sqlalchemy.orm import Mapped, mapped_column from app.database.session import Base class User(Base): """ 사용자 테이블 (카카오 로그인) Attributes: id: 고유 식별자 (자동 증가) kakao_id: 카카오 고유 ID nickname: 카카오 닉네임 email: 카카오 이메일 (선택) profile_image: 프로필 이미지 URL created_at: 가입 일시 last_login_at: 마지막 로그인 일시 """ __tablename__ = "user" __table_args__ = ( Index("idx_user_kakao_id", "kakao_id"), { "mysql_engine": "InnoDB", "mysql_charset": "utf8mb4", "mysql_collate": "utf8mb4_unicode_ci", }, ) id: Mapped[int] = mapped_column( Integer, primary_key=True, nullable=False, autoincrement=True, comment="고유 식별자", ) kakao_id: Mapped[str] = mapped_column( String(50), nullable=False, unique=True, comment="카카오 고유 ID", ) nickname: Mapped[str | None] = mapped_column( String(100), nullable=True, comment="카카오 닉네임", ) email: Mapped[str | None] = mapped_column( String(255), nullable=True, comment="카카오 이메일", ) profile_image: Mapped[str | None] = mapped_column( String(500), nullable=True, comment="프로필 이미지 URL", ) created_at: Mapped[datetime] = mapped_column( DateTime, nullable=False, server_default=func.now(), comment="가입 일시", ) last_login_at: Mapped[datetime] = mapped_column( DateTime, nullable=False, server_default=func.now(), onupdate=func.now(), comment="마지막 로그인 일시", ) def __repr__(self) -> str: return f""