some fixes for models

This commit is contained in:
2021-08-19 18:33:39 +03:00
parent 0cb0b85bce
commit 94518adcc5
10 changed files with 31 additions and 38 deletions

View File

@@ -4,7 +4,7 @@ from orm.base import Base
class Notification(Base):
__tablename__ = 'notification'
kind: str = Column(String, primary_key = True)
kind: str = Column(String, unique = True, primary_key = True)
template: str = Column(String, nullable = False)
variables: JSONType = Column(JSONType, nullable = True) # [ <var1>, .. ]
@@ -12,6 +12,6 @@ class UserNotification(Base):
__tablename__ = 'user_notification'
id: int = Column(Integer, primary_key = True)
user: int = Column(ForeignKey("user.id"))
kind: int = Column(ForeignKey("notification.kind"), nullable = False)
user_id: int = Column(Integer, ForeignKey("user.id"))
kind: str = Column(String, ForeignKey("notification.kind"))
values: JSONType = Column(JSONType, nullable = True) # [ <var1>, .. ]