31 lines
1.6 KiB
Python
31 lines
1.6 KiB
Python
from sqlalchemy import DateTime, DECIMAL, ForeignKey, SmallInteger, String, UniqueConstraint
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from app.database import Base
|
|
|
|
|
|
class MatchLike(Base):
|
|
__tablename__ = "match_likes"
|
|
__table_args__ = (UniqueConstraint("from_user_id", "to_user_id", name="uk_like"),)
|
|
|
|
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
|
|
from_user_id: Mapped[int] = mapped_column(ForeignKey("users.id"), nullable=False)
|
|
to_user_id: Mapped[int] = mapped_column(ForeignKey("users.id"), nullable=False)
|
|
source: Mapped[str] = mapped_column(String(20), default="manual", nullable=False)
|
|
created_at: Mapped[DateTime] = mapped_column(DateTime, nullable=False)
|
|
|
|
|
|
class Match(Base):
|
|
__tablename__ = "matches"
|
|
__table_args__ = (UniqueConstraint("user_a_id", "user_b_id", name="uk_match"),)
|
|
|
|
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
|
|
user_a_id: Mapped[int] = mapped_column(ForeignKey("users.id"), nullable=False)
|
|
user_b_id: Mapped[int] = mapped_column(ForeignKey("users.id"), nullable=False)
|
|
match_score: Mapped[float | None] = mapped_column(DECIMAL(5, 2))
|
|
match_type: Mapped[str] = mapped_column(String(20), default="manual", nullable=False)
|
|
source_activity_id: Mapped[int | None] = mapped_column(ForeignKey("activities.id"))
|
|
a_viewed: Mapped[int] = mapped_column(SmallInteger, default=0, nullable=False)
|
|
b_viewed: Mapped[int] = mapped_column(SmallInteger, default=0, nullable=False)
|
|
matched_at: Mapped[DateTime] = mapped_column(DateTime, nullable=False)
|