migration-orm-fixes
This commit is contained in:
@@ -17,16 +17,14 @@ class CommentRating(Base):
|
||||
|
||||
class Comment(Base):
|
||||
__tablename__ = 'comment'
|
||||
|
||||
author: int = Column(ForeignKey("user.id"), nullable=False, comment="Sender")
|
||||
body: str = Column(String, nullable=False, comment="Comment Body")
|
||||
createdAt = Column(DateTime, nullable=False, default = datetime.now, comment="Created at")
|
||||
createdBy: str = Column(ForeignKey("user.slug"), nullable=False, comment="Sender")
|
||||
updatedAt = Column(DateTime, nullable=True, comment="Updated at")
|
||||
updatedBy = Column(ForeignKey("user.id"), nullable=True, comment="Last Editor")
|
||||
updatedBy = Column(ForeignKey("user.slug"), nullable=True, comment="Last Editor")
|
||||
deletedAt = Column(DateTime, nullable=True, comment="Deleted at")
|
||||
deletedBy = Column(ForeignKey("user.id"), nullable=True, comment="Deleted by")
|
||||
deletedBy = Column(ForeignKey("user.slug"), nullable=True, comment="Deleted by")
|
||||
shout = Column(ForeignKey("shout.slug"), nullable=False)
|
||||
replyTo: int = Column(ForeignKey("comment.id"), nullable=True, comment="comment ID")
|
||||
ratings = relationship(CommentRating, foreign_keys=CommentRating.comment_id)
|
||||
|
||||
# TODO: work in progress, udpate this code
|
||||
oid: str = Column(String, nullable=True)
|
@@ -16,11 +16,11 @@ class Community(Base):
|
||||
__tablename__ = 'community'
|
||||
|
||||
name: str = Column(String, nullable=False, comment="Name")
|
||||
slug: str = Column(String, unique = True, nullable = False)
|
||||
slug: str = Column(String, nullable = False)
|
||||
desc: str = Column(String, nullable=False, default='')
|
||||
pic: str = Column(String, nullable=False, default='')
|
||||
createdAt: str = Column(DateTime, nullable=False, default = datetime.now, comment="Created at")
|
||||
createdBy: str = Column(ForeignKey("user.id"), nullable=False, comment="Creator")
|
||||
createdBy: str = Column(ForeignKey("user.slug"), nullable=False, comment="Creator")
|
||||
|
||||
@staticmethod
|
||||
def init_table():
|
||||
|
@@ -328,14 +328,14 @@ class Shout(Base):
|
||||
id = None
|
||||
|
||||
slug: str = Column(String, primary_key=True)
|
||||
community: int = Column(Integer, ForeignKey("community.id"), nullable=False, comment="Community")
|
||||
community: str = Column(Integer, ForeignKey("community.id"), nullable=False, comment="Community")
|
||||
body: str = Column(String, nullable=False, comment="Body")
|
||||
createdAt: str = Column(DateTime, nullable=False, default = datetime.now, comment="Created at")
|
||||
updatedAt: str = Column(DateTime, nullable=True, comment="Updated at")
|
||||
replyTo: int = Column(ForeignKey("shout.slug"), nullable=True)
|
||||
versionOf: int = Column(ForeignKey("shout.slug"), nullable=True)
|
||||
tags: str = Column(String, nullable=True)
|
||||
publishedBy: bool = Column(ForeignKey("user.id"), nullable=True)
|
||||
publishedBy: int = Column(ForeignKey("user.id"), nullable=True)
|
||||
publishedAt: str = Column(DateTime, nullable=True)
|
||||
cover: str = Column(String, nullable = True)
|
||||
title: str = Column(String, nullable = True)
|
||||
@@ -346,6 +346,8 @@ class Shout(Base):
|
||||
topics = relationship(lambda: Topic, secondary=ShoutTopic.__tablename__)
|
||||
mainTopic = Column(ForeignKey("topic.slug"), nullable=True)
|
||||
visibleFor = relationship(lambda: User, secondary=ShoutViewer.__tablename__)
|
||||
draft: bool = Column(Boolean, default=True)
|
||||
oid: str = Column(String, nullable=True)
|
||||
|
||||
@property
|
||||
async def stat(self):
|
||||
|
@@ -24,6 +24,7 @@ class Topic(Base):
|
||||
pic: str = Column(String, nullable=True, comment="Picture")
|
||||
children = Column(JSONType, nullable=True, default = [], comment="list of children topics")
|
||||
community = Column(ForeignKey("community.slug"), nullable=False, comment="Community")
|
||||
oid: str = Column(String, nullable=True, comment="Old ID")
|
||||
|
||||
class TopicStorage:
|
||||
topics = {}
|
||||
|
@@ -68,7 +68,7 @@ class User(Base):
|
||||
notifications = relationship(lambda: UserNotifications)
|
||||
ratings = relationship(UserRating, foreign_keys=UserRating.user)
|
||||
roles = relationship(lambda: Role, secondary=UserRole.__tablename__)
|
||||
old_id: str = Column(String, nullable = True)
|
||||
oid: str = Column(String, nullable = True)
|
||||
|
||||
@staticmethod
|
||||
def init_table():
|
||||
|
Reference in New Issue
Block a user