20 lines
693 B
Python
20 lines
693 B
Python
from sqlalchemy import String, ForeignKey, Index, UniqueConstraint
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from app.models.base import Base, TimestampMixin
|
|
|
|
|
|
class NotificationRead(Base, TimestampMixin):
|
|
__tablename__ = "notification_reads"
|
|
|
|
id: Mapped[str] = mapped_column(String(32), primary_key=True)
|
|
notification_id: Mapped[str] = mapped_column(
|
|
String(32), ForeignKey("notifications.id"), index=True
|
|
)
|
|
user_id: Mapped[str] = mapped_column(String(32), index=True)
|
|
|
|
__table_args__ = (
|
|
UniqueConstraint('notification_id', 'user_id', name='uq_notif_read_user'),
|
|
Index('idx_notif_read_user_notif', 'user_id', 'notification_id'),
|
|
)
|