import datetime as dt from sqlalchemy import ( BigInteger, DateTime, ForeignKey, func, ) from sqlalchemy.orm import Mapped, mapped_column from app.db.database import Base class User(Base): __tablename__ = "user" id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True) fullname: Mapped[str] = mapped_column() tg_id: Mapped[int] = mapped_column(BigInteger) phone: Mapped[str] = mapped_column(nullable=True) class Event(Base): __tablename__ = "event" id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True) title: Mapped[str] = mapped_column() description: Mapped[str] = mapped_column(default="") start_date: Mapped[dt.date] = mapped_column(nullable=True) end_date: Mapped[dt.date] = mapped_column(nullable=True) class UserEvent(Base): __tablename__ = "user_event" id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True) user: Mapped[int] = mapped_column(ForeignKey("user.id")) event: Mapped[int] = mapped_column(ForeignKey("event.id")) date: Mapped[dt.date] = mapped_column( DateTime(timezone=True), server_default=func.now() ) status: Mapped[str] = mapped_column(default="not confirmed")