notification-model-fix

This commit is contained in:
2024-01-23 12:05:28 +03:00
parent 140e46e9f2
commit ac424cf803
3 changed files with 17 additions and 17 deletions

View File

@@ -1,7 +1,7 @@
from enum import Enum as Enumeration
from sqlalchemy import JSON as JSONType, func, cast
from sqlalchemy import Column, Enum, ForeignKey, Integer
from sqlalchemy import Column, Enum, ForeignKey, Integer, String
from sqlalchemy.orm import relationship
from sqlalchemy.orm.session import engine
@@ -10,18 +10,18 @@ from services.db import Base
import time
class NotificationEntity(Enumeration):
REACTION = 1
SHOUT = 2
FOLLOWER = 3
REACTION = "reaction"
SHOUT = "shout"
FOLLOWER = "follower"
class NotificationAction(Enumeration):
CREATE = 1
UPDATE = 2
DELETE = 3
SEEN = 4
FOLLOW = 5
UNFOLLOW = 6
CREATE = "create"
UPDATE = "update"
DELETE = "delete"
SEEN = "seen"
FOLLOW = "follow"
UNFOLLOW = "unfollow"
class NotificationSeen(Base):
@@ -35,8 +35,8 @@ class Notification(Base):
__tablename__ = "notification"
created_at = Column(Integer, server_default=str(int(time.time())))
entity = Column(Enum(NotificationEntity), nullable=False)
action = Column(Enum(NotificationAction), nullable=False)
entity = Column(String, nullable=False)
action = Column(String, nullable=False)
payload = Column(JSONType, nullable=True)
seen = relationship(lambda: Author, secondary="notification_seen")