commit
9c5fef1a4d
412 files changed
+94582
No files matched your search
@@ -0,0 +1,22 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from sqlalchemy import DateTime, ForeignKey, Index, JSON, String, UniqueConstraint
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
|
||||
from sakura_cloud.db.base import Base
|
||||
from sakura_cloud.models.mixins import TimestampMixin, UUIDPrimaryKeyMixin
|
||||
|
||||
|
||||
class FeedCache(UUIDPrimaryKeyMixin, TimestampMixin, Base):
|
||||
__tablename__ = "feed_cache"
|
||||
__table_args__ = (
|
||||
UniqueConstraint("user_id", "cache_key", name="uq_feed_cache_user_key"),
|
||||
Index("ix_feed_cache_user_expires", "user_id", "expires_at"),
|
||||
)
|
||||
|
||||
user_id: Mapped[str] = mapped_column(String(36), ForeignKey("users.id", ondelete="CASCADE"), nullable=False)
|
||||
cache_key: Mapped[str] = mapped_column(String(100), nullable=False)
|
||||
payload: Mapped[list[dict]] = mapped_column(JSON, default=list, nullable=False)
|
||||
expires_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), nullable=False)
|
||||
Reference in new issue
Block a user