core/orm/notification.py

27 lines
860 B
Python
Raw Permalink Normal View History

2023-10-30 21:00:55 +00:00
from enum import Enum as Enumeration
from sqlalchemy import Boolean, Column, DateTime, Enum, ForeignKey, Integer, func
from sqlalchemy.dialects.postgresql import JSONB
2023-10-26 21:07:35 +00:00
from base.orm import Base
class NotificationType(Enumeration):
NEW_COMMENT = 1
NEW_REPLY = 2
2022-09-03 10:50:14 +00:00
class Notification(Base):
2022-09-03 10:50:14 +00:00
__tablename__ = "notification"
2023-10-30 21:00:55 +00:00
shout: Column = Column(ForeignKey("shout.id"), index=True)
reaction: Column = Column(ForeignKey("reaction.id"), index=True)
user: Column = Column(ForeignKey("user.id"), index=True)
createdAt = Column(
DateTime(timezone=True), nullable=False, server_default=func.now(), index=True
)
seen = Column(Boolean, nullable=False, default=False, index=True)
type = Column(Enum(NotificationType), nullable=False)
data = Column(JSONB, nullable=True)
occurrences = Column(Integer, default=1)