Migration fix, notification schema update

This commit is contained in:
Igor Lobanov
2023-10-09 12:52:13 +02:00
parent a9b26254ce
commit 6e149432c1
4 changed files with 328 additions and 304 deletions

View File

@@ -1,13 +1,22 @@
from datetime import datetime
from sqlalchemy import Column, String, JSON, ForeignKey, DateTime, Boolean
from sqlalchemy import Column, Enum, JSON, ForeignKey, DateTime, Boolean, Integer
from base.orm import Base
from enum import Enum as Enumeration
class NotificationType(Enumeration):
NEW_COMMENT = 1
NEW_REPLY = 2
class Notification(Base):
__tablename__ = "notification"
shout = Column(ForeignKey("shout.id"), index=True)
reaction = Column(ForeignKey("reaction.id"), index=True)
user = Column(ForeignKey("user.id"), index=True)
createdAt = Column(DateTime, nullable=False, default=datetime.now, index=True)
seen = Column(Boolean, nullable=False, default=False, index=True)
type = Column(String, nullable=False)
type = Column(Enum(NotificationType), nullable=False)
data = Column(JSON, nullable=True)
occurrences = Column(Integer, default=1)