feat: add download_token field to Config model
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import secrets
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from sqlalchemy import (
|
from sqlalchemy import (
|
||||||
Boolean, DateTime, ForeignKey, Integer, String, Text, UniqueConstraint, func
|
Boolean, DateTime, ForeignKey, Integer, String, Text, UniqueConstraint, func
|
||||||
@@ -27,6 +28,11 @@ class Config(Base):
|
|||||||
is_active: Mapped[bool] = mapped_column(Boolean, default=True)
|
is_active: Mapped[bool] = mapped_column(Boolean, default=True)
|
||||||
created_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now())
|
created_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now())
|
||||||
updated_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now(), onupdate=func.now())
|
updated_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now(), onupdate=func.now())
|
||||||
|
download_token: Mapped[str] = mapped_column(
|
||||||
|
String(64),
|
||||||
|
nullable=False,
|
||||||
|
default=lambda: secrets.token_urlsafe(32),
|
||||||
|
)
|
||||||
owner_id: Mapped[int] = mapped_column(Integer, ForeignKey("users.id"), nullable=False)
|
owner_id: Mapped[int] = mapped_column(Integer, ForeignKey("users.id"), nullable=False)
|
||||||
|
|
||||||
owner: Mapped["User"] = relationship("User", back_populates="configs")
|
owner: Mapped["User"] = relationship("User", back_populates="configs")
|
||||||
|
|||||||
Reference in New Issue
Block a user