modify db schema
This commit is contained in:
15
orm/user.py
15
orm/user.py
@@ -5,7 +5,6 @@ from sqlalchemy.orm import relationship
|
||||
|
||||
from orm import Permission
|
||||
from orm.base import Base, local_session
|
||||
from orm.rating import Rating
|
||||
from orm.rbac import Role
|
||||
|
||||
class UserNotifications(Base):
|
||||
@@ -16,11 +15,13 @@ class UserNotifications(Base):
|
||||
kind: str = Column(String, ForeignKey("notification.kind"))
|
||||
values: JSONType = Column(JSONType, nullable = True) # [ <var1>, .. ]
|
||||
|
||||
UserRatings = Table("user_ratings",
|
||||
Base.metadata,
|
||||
Column('user_id', Integer, ForeignKey('user.id')),
|
||||
Column('rater_id', Integer, ForeignKey('rating.createdBy'))
|
||||
)
|
||||
class UserRatings(Base):
|
||||
__tablename__ = "user_ratings"
|
||||
|
||||
id = None
|
||||
rater_id = Column(ForeignKey('user.id'), primary_key = True)
|
||||
user_id = Column(ForeignKey('user.id'), primary_key = True)
|
||||
value = Column(Integer)
|
||||
|
||||
UserRoles = Table("user_roles",
|
||||
Base.metadata,
|
||||
@@ -46,7 +47,7 @@ class User(Base):
|
||||
links: JSONType = Column(JSONType, nullable=True, comment="Links")
|
||||
oauth: str = Column(String, nullable=True)
|
||||
notifications = relationship(lambda: UserNotifications)
|
||||
ratings = relationship(lambda: Rating, secondary=UserRatings)
|
||||
ratings = relationship(UserRatings, foreign_keys=UserRatings.user_id)
|
||||
roles = relationship(lambda: Role, secondary=UserRoles)
|
||||
|
||||
@classmethod
|
||||
|
Reference in New Issue
Block a user