feat(link_codes): linking method between telegram and website
This commit is contained in:
28
db/models/link_codes.py
Normal file
28
db/models/link_codes.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from datetime import UTC, datetime
|
||||
|
||||
from sqlalchemy import TEXT, DateTime, Enum, ForeignKey
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
|
||||
from db.base import Base
|
||||
from schemas.enums import LinkCodeStatus
|
||||
|
||||
|
||||
class LinkCode(Base):
|
||||
__tablename__ = "link_codes"
|
||||
|
||||
code: Mapped[str] = mapped_column(TEXT, nullable=False, unique=True, primary_key=True)
|
||||
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"), nullable=False)
|
||||
status: Mapped[LinkCodeStatus] = mapped_column(
|
||||
Enum(LinkCodeStatus, name="linkcodestatus"), nullable=False, default=LinkCodeStatus.ACTIVE
|
||||
)
|
||||
|
||||
created_at: Mapped[datetime] = mapped_column(
|
||||
DateTime(timezone=True),
|
||||
nullable=False,
|
||||
default=lambda: datetime.now(UTC),
|
||||
)
|
||||
expires_at: Mapped[datetime] = mapped_column(
|
||||
DateTime(timezone=True),
|
||||
nullable=False,
|
||||
)
|
||||
used_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), nullable=True)
|
||||
Reference in New Issue
Block a user