diff --git a/server/szurubooru/db/comment.py b/server/szurubooru/db/comment.py index bbb8b189..bf325859 100644 --- a/server/szurubooru/db/comment.py +++ b/server/szurubooru/db/comment.py @@ -8,11 +8,16 @@ class CommentScore(Base): __tablename__ = 'comment_score' comment_id = Column( - 'comment_id', Integer, ForeignKey('comment.id'), primary_key=True) + 'comment_id', + Integer, + ForeignKey('comment.id'), + nullable=False, + primary_key=True) user_id = Column( 'user_id', Integer, ForeignKey('user.id'), + nullable=False, primary_key=True, index=True) time = Column('time', DateTime, nullable=False) @@ -29,8 +34,9 @@ class Comment(Base): comment_id = Column('id', Integer, primary_key=True) post_id = Column( - 'post_id', Integer, ForeignKey('post.id'), index=True, nullable=False) - user_id = Column('user_id', Integer, ForeignKey('user.id'), index=True) + 'post_id', Integer, ForeignKey('post.id'), nullable=False, index=True) + user_id = Column( + 'user_id', Integer, ForeignKey('user.id'), nullable=True, index=True) version = Column('version', Integer, default=1, nullable=False) creation_time = Column('creation_time', DateTime, nullable=False) last_edit_time = Column('last_edit_time', DateTime) diff --git a/server/szurubooru/db/post.py b/server/szurubooru/db/post.py index d68b4e38..65942d37 100644 --- a/server/szurubooru/db/post.py +++ b/server/szurubooru/db/post.py @@ -31,12 +31,14 @@ class PostScore(Base): Integer, ForeignKey('post.id'), primary_key=True, + nullable=False, index=True) user_id = Column( 'user_id', Integer, ForeignKey('user.id'), primary_key=True, + nullable=False, index=True) time = Column('time', DateTime, nullable=False) score = Column('score', Integer, nullable=False) @@ -55,12 +57,14 @@ class PostFavorite(Base): Integer, ForeignKey('post.id'), primary_key=True, + nullable=False, index=True) user_id = Column( 'user_id', Integer, ForeignKey('user.id'), primary_key=True, + nullable=False, index=True) time = Column('time', DateTime, nullable=False) @@ -90,12 +94,14 @@ class PostRelation(Base): Integer, ForeignKey('post.id'), primary_key=True, + nullable=False, index=True) child_id = Column( 'child_id', Integer, ForeignKey('post.id'), primary_key=True, + nullable=False, index=True) def __init__(self, parent_id, child_id): @@ -111,9 +117,15 @@ class PostTag(Base): Integer, ForeignKey('post.id'), primary_key=True, + nullable=False, index=True) tag_id = Column( - 'tag_id', Integer, ForeignKey('tag.id'), primary_key=True, index=True) + 'tag_id', + Integer, + ForeignKey('tag.id'), + primary_key=True, + nullable=False, + index=True) def __init__(self, post_id, tag_id): self.post_id = post_id diff --git a/server/szurubooru/db/snapshot.py b/server/szurubooru/db/snapshot.py index f0a497bd..45f1077a 100644 --- a/server/szurubooru/db/snapshot.py +++ b/server/szurubooru/db/snapshot.py @@ -19,7 +19,10 @@ class Snapshot(Base): resource_repr = Column('resource_repr', Unicode(64), nullable=False) operation = Column('operation', Unicode(16), nullable=False) user_id = Column( - 'user_id', Integer, ForeignKey('user.id', ondelete='set null')) + 'user_id', + Integer, + ForeignKey('user.id', ondelete='set null'), + nullable=True) data = Column('data', PickleType) user = relationship('User') diff --git a/server/szurubooru/db/tag.py b/server/szurubooru/db/tag.py index 5dae8c8b..94b1c2c5 100644 --- a/server/szurubooru/db/tag.py +++ b/server/szurubooru/db/tag.py @@ -13,12 +13,16 @@ class TagSuggestion(Base): 'parent_id', Integer, ForeignKey('tag.id'), - primary_key=True, index=True) + nullable=False, + primary_key=True, + index=True) child_id = Column( 'child_id', Integer, ForeignKey('tag.id'), - primary_key=True, index=True) + nullable=False, + primary_key=True, + index=True) def __init__(self, parent_id, child_id): self.parent_id = parent_id @@ -32,12 +36,14 @@ class TagImplication(Base): 'parent_id', Integer, ForeignKey('tag.id'), + nullable=False, primary_key=True, index=True) child_id = Column( 'child_id', Integer, ForeignKey('tag.id'), + nullable=False, primary_key=True, index=True)