model upgrade

This commit is contained in:
2021-08-20 11:08:32 +03:00
parent 94518adcc5
commit ee3b186ba1
8 changed files with 85 additions and 38 deletions

18
orm/topic.py Normal file
View File

@@ -0,0 +1,18 @@
from typing import List
from datetime import datetime
from sqlalchemy import Column, Integer, String, ForeignKey, DateTime
from sqlalchemy.orm import relationship, backref
from orm import Permission
from orm.base import Base
class Topic(Base):
__tablename__ = 'topic'
slug: str = Column(String, unique = True, nullable = False, primary_key=True)
org_id: str = Column(ForeignKey("organization.id"), nullable=False)
createdAt: str = Column(DateTime, nullable=False, default = datetime.now, comment="Created at")
createdBy: str = Column(ForeignKey("user.id"), nullable=False, comment="Author")
value: str = Column(String, nullable=False, comment="Value")
alters = relationship(lambda: Topic, backref=backref("topic", remote_side=[slug]))
alter_id: str = Column(ForeignKey("topic.slug"))
# TODO: add all the fields