This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
from enum import Enum as Enumeration
|
||||
import time
|
||||
from sqlalchemy import Boolean, Column, Enum, Integer
|
||||
from sqlalchemy.dialects.postgresql import JSONB
|
||||
|
||||
from sqlalchemy import Boolean, Column, Enum, Integer, ForeignKey, JSON as JSONType
|
||||
from sqlalchemy.orm import relationship
|
||||
# from sqlalchemy.dialects.postgresql import JSONB
|
||||
from orm.author import Author
|
||||
from services.db import Base
|
||||
|
||||
|
||||
@@ -21,12 +22,19 @@ class NotificationAction(Enumeration):
|
||||
UNFOLLOW = 6
|
||||
|
||||
|
||||
class NotificationSeen(Base):
|
||||
__tablename__ = "notification_seen"
|
||||
|
||||
viewer = Column(ForeignKey("author.id"))
|
||||
notification = Column(ForeignKey("notification.id"))
|
||||
|
||||
|
||||
class Notification(Base):
|
||||
__tablename__ = "notification"
|
||||
|
||||
created_at = Column(Integer, default=lambda: int(time.time()))
|
||||
seen = Column(Boolean, nullable=False, default=False, index=True)
|
||||
entity = Column(Enum(NotificationEntity), nullable=False)
|
||||
action = Column(Enum(NotificationAction), nullable=False)
|
||||
payload = Column(JSONB, nullable=True)
|
||||
# occurrences = Column(Integer, default=1)
|
||||
payload = Column(JSONType, nullable=True)
|
||||
|
||||
seen = relationship(lambda: Author, secondary="notification_seen")
|
||||
|
Reference in New Issue
Block a user