Files
video-gen/video-gen-api/app/models/notification.py
T
2026-06-29 09:09:58 +08:00

23 lines
880 B
Python

from sqlalchemy import Boolean, ForeignKey, String, Text, Index
from sqlalchemy.orm import Mapped, mapped_column
from app.models.base import Base, TimestampMixin
class Notification(Base, TimestampMixin):
__tablename__ = "notifications"
id: Mapped[str] = mapped_column(String(32), primary_key=True)
user_id: Mapped[str | None] = mapped_column(
String(32), ForeignKey("users.id", ondelete="CASCADE"), nullable=True, index=True
)
title: Mapped[str] = mapped_column(String(128))
content: Mapped[str] = mapped_column(Text)
type: Mapped[str] = mapped_column(String(32), default="system")
is_read: Mapped[bool] = mapped_column(Boolean, default=False)
related_id: Mapped[str | None] = mapped_column(String(64), nullable=True)
__table_args__ = (
Index('idx_notif_user_isread_created', 'user_id', 'is_read', 'created_at'),
)