aftermerge, migration fixed
This commit is contained in:
@@ -11,7 +11,7 @@ class Like(Base):
|
||||
|
||||
id: int = None
|
||||
user_id: str = Column(ForeignKey("user.id"), comment="Author", primary_key = True)
|
||||
shout: str = Column(String, ForeignKey("shout.slug"), comment="Liked shout slug", primary_key = True)
|
||||
shout_id: int = Column(Integer, ForeignKey("shout.id"), comment="Liked shout id", primary_key = True)
|
||||
value: int = Column(Integer, nullable=False, comment="Value")
|
||||
|
||||
# TODO: add resolvers, debug, etc.
|
||||
|
@@ -10,9 +10,9 @@ class Proposal(Base):
|
||||
__tablename__ = 'proposal'
|
||||
|
||||
author_id: int = Column(Integer, ForeignKey("user.id"), nullable=False, comment="Author")
|
||||
shout_id: int = Column(Integer, ForeignKey("shout.id"), nullable=False, comment="Shout")
|
||||
body: str = Column(String, nullable=False, comment="Body")
|
||||
createdAt: str = Column(datetime, nullable=False, comment="Created at")
|
||||
shout: str = Column(String, ForeignKey("shout.slug"), nullable=False, comment="Updated at")
|
||||
range: str = Column(String, nullable=True, comment="Range in format <start index>:<end>")
|
||||
|
||||
# TODO: debug, logix
|
@@ -1,3 +0,0 @@
|
||||
from sqlalchemy import Column, Integer, String, ForeignKey
|
||||
# from orm import Permission
|
||||
from orm.base import Base
|
@@ -24,7 +24,7 @@ class ClassType(TypeDecorator):
|
||||
def process_result_value(self, value, dialect):
|
||||
class_ = REGISTRY.get(value)
|
||||
if class_ is None:
|
||||
warnings.warn(f"Can't find class <{value}>,find it yourself 😊", stacklevel=2)
|
||||
warnings.warn(f"Can't find class <{value}>,find it yourself!", stacklevel=2)
|
||||
return class_
|
||||
|
||||
class Organization(Base):
|
||||
|
27
orm/shout.py
27
orm/shout.py
@@ -7,31 +7,46 @@ from orm.base import Base
|
||||
|
||||
ShoutAuthors = Table('shout_authors',
|
||||
Base.metadata,
|
||||
Column('shout', String, ForeignKey('shout.slug')),
|
||||
Column('shout', Integer, ForeignKey('shout.id')),
|
||||
Column('user_id', Integer, ForeignKey('user.id'))
|
||||
)
|
||||
|
||||
ShoutTopics = Table('shout_topics',
|
||||
Base.metadata,
|
||||
Column('shout', String, ForeignKey('shout.slug')),
|
||||
Column('topic', String, ForeignKey('topic.slug'))
|
||||
Column('shout', Integer, ForeignKey('shout.id')),
|
||||
Column('topic', Integer, ForeignKey('topic.id'))
|
||||
)
|
||||
|
||||
class ShoutRatings(Base):
|
||||
__tablename__ = "user_ratings"
|
||||
|
||||
id = None
|
||||
rater_id = Column(ForeignKey('user.id'), primary_key = True)
|
||||
shout_id = Column(ForeignKey('shout.id'), primary_key = True)
|
||||
value = Column(Integer)
|
||||
|
||||
class Shout(Base):
|
||||
__tablename__ = 'shout'
|
||||
|
||||
slug: str = Column(String, primary_key=True)
|
||||
# NOTE: automatic ID here
|
||||
|
||||
slug: str = Column(String, nullable=False, unique=True)
|
||||
org_id: int = Column(Integer, ForeignKey("organization.id"), nullable=False, comment="Organization")
|
||||
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: str = Column(ForeignKey("shout.slug"), nullable=True)
|
||||
versionOf: str = Column(ForeignKey("shout.slug"), nullable=True)
|
||||
replyTo: int = Column(ForeignKey("shout.id"), nullable=True)
|
||||
versionOf: int = Column(ForeignKey("shout.id"), nullable=True)
|
||||
tags: str = Column(String, nullable=True)
|
||||
views: int = Column(Integer, default=0)
|
||||
published: bool = Column(Boolean, default=False)
|
||||
publishedAt: str = Column(DateTime, nullable=True)
|
||||
cover: str = Column(String, nullable = True)
|
||||
title: str = Column(String, nullable = True)
|
||||
subtitle: str = Column(String, nullable = True)
|
||||
layout: str = Column(String, nullable = True)
|
||||
authors = relationship(lambda: User, secondary=ShoutAuthors) # NOTE: multiple authors
|
||||
topics = relationship(lambda: Topic, secondary=ShoutTopics)
|
||||
rating: int = Column(Integer, nullable=True, comment="Rating")
|
||||
ratings = relationship(ShoutRatings, foreign_keys=ShoutRatings.shout_id)
|
||||
old_id: str = Column(String, nullable = True)
|
||||
|
@@ -8,8 +8,8 @@ from orm.base import Base
|
||||
|
||||
Connection = Table('topic_connections',
|
||||
Base.metadata,
|
||||
Column('child', String, ForeignKey('topic.slug')),
|
||||
Column('parent', String, ForeignKey('topic.slug')),
|
||||
Column('child', Integer, ForeignKey('topic.id')),
|
||||
Column('parent', Integer, ForeignKey('topic.id')),
|
||||
UniqueConstraint('parent', 'child', name='unique_usage')
|
||||
)
|
||||
|
||||
@@ -17,8 +17,7 @@ Connection = Table('topic_connections',
|
||||
class Topic(Base):
|
||||
__tablename__ = 'topic'
|
||||
|
||||
id: int = None
|
||||
slug: str = Column(String, unique = True, nullable = False, primary_key=True)
|
||||
slug: str = Column(String, unique = True, nullable = False)
|
||||
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")
|
||||
|
Reference in New Issue
Block a user