commit
9c5fef1a4d
412 files changed
+94582
No files matched your search
@@ -0,0 +1,60 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from sqlalchemy import Boolean, DateTime, ForeignKey, Index, JSON, String, Text
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from sakura_cloud.db.base import Base
|
||||
from sakura_cloud.models.mixins import TimestampMixin, UUIDPrimaryKeyMixin
|
||||
|
||||
|
||||
class CreatorFollow(UUIDPrimaryKeyMixin, TimestampMixin, Base):
|
||||
__tablename__ = "creator_follows"
|
||||
__table_args__ = (
|
||||
Index("ix_creator_follows_user_enabled_updated", "user_id", "enabled", "updated_at"),
|
||||
Index("ix_creator_follows_user_platform_creator", "user_id", "platform", "creator_id"),
|
||||
)
|
||||
|
||||
user_id: Mapped[str] = mapped_column(String(36), ForeignKey("users.id", ondelete="CASCADE"), nullable=False, index=True)
|
||||
platform: Mapped[str] = mapped_column(String(20), nullable=False, index=True)
|
||||
creator_id: Mapped[str] = mapped_column(String(100), nullable=False, index=True)
|
||||
creator_name: Mapped[str | None] = mapped_column(String(200), nullable=True)
|
||||
creator_handle: Mapped[str | None] = mapped_column(String(200), nullable=True)
|
||||
profile_url: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
avatar_url: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
enabled: Mapped[bool] = mapped_column(Boolean, default=True, nullable=False, index=True)
|
||||
last_checked_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True)
|
||||
latest_published_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True)
|
||||
metadata_json: Mapped[dict] = mapped_column("metadata", JSON, default=dict, nullable=False)
|
||||
|
||||
user = relationship("User", back_populates="creator_follows")
|
||||
|
||||
|
||||
class UpdateAlert(UUIDPrimaryKeyMixin, TimestampMixin, Base):
|
||||
__tablename__ = "update_alerts"
|
||||
__table_args__ = (
|
||||
Index("ix_update_alerts_user_read_created", "user_id", "is_read", "created_at"),
|
||||
Index("ix_update_alerts_user_created", "user_id", "created_at"),
|
||||
Index("ix_update_alerts_user_platform_creator", "user_id", "platform", "creator_id"),
|
||||
)
|
||||
|
||||
user_id: Mapped[str] = mapped_column(String(36), ForeignKey("users.id", ondelete="CASCADE"), nullable=False, index=True)
|
||||
follow_id: Mapped[str | None] = mapped_column(
|
||||
String(36),
|
||||
ForeignKey("creator_follows.id", ondelete="SET NULL"),
|
||||
nullable=True,
|
||||
index=True,
|
||||
)
|
||||
platform: Mapped[str] = mapped_column(String(20), nullable=False, index=True)
|
||||
creator_id: Mapped[str] = mapped_column(String(100), nullable=False, index=True)
|
||||
title: Mapped[str] = mapped_column(String(500), nullable=False)
|
||||
body: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
content_type: Mapped[str | None] = mapped_column(String(20), nullable=True)
|
||||
target_url: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
cover_url: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
is_read: Mapped[bool] = mapped_column(Boolean, default=False, nullable=False, index=True)
|
||||
payload_json: Mapped[dict] = mapped_column("payload", JSON, default=dict, nullable=False)
|
||||
|
||||
user = relationship("User", back_populates="update_alerts")
|
||||
follow = relationship("CreatorFollow")
|
||||
Reference in new issue
Block a user