db/update models

This commit is contained in:
SouthFox 2023-03-20 22:11:44 +08:00
parent ce426a20c2
commit 7686413262
2 changed files with 7 additions and 0 deletions

View file

@ -34,6 +34,7 @@ def upgrade() -> None:
sa.Column('activity_object_ap_id', sa.String(), nullable=True), sa.Column('activity_object_ap_id', sa.String(), nullable=True),
sa.Column('visibility', sa.Enum('PUBLIC', 'UNLISTED', 'FOLLOWERS_ONLY', 'DIRECT', name='visibilityenum'), nullable=False), sa.Column('visibility', sa.Enum('PUBLIC', 'UNLISTED', 'FOLLOWERS_ONLY', 'DIRECT', name='visibilityenum'), nullable=False),
sa.Column('undo_id', sa.Integer(), nullable=False), sa.Column('undo_id', sa.Integer(), nullable=False),
sa.Column('is_deleted', sa.Boolean(), nullable=False),
sa.Column('relates_to_inbox_object_id', sa.Integer(), nullable=True), sa.Column('relates_to_inbox_object_id', sa.Integer(), nullable=True),
sa.Column('relates_to_outbox_object_id', sa.Integer(), nullable=True), sa.Column('relates_to_outbox_object_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['actor_id'], ['actor.id'], ), sa.ForeignKeyConstraint(['actor_id'], ['actor.id'], ),
@ -58,6 +59,8 @@ def upgrade() -> None:
sa.Column('ap_object', sa.JSON(), nullable=False), sa.Column('ap_object', sa.JSON(), nullable=False),
sa.Column('activity_object_ap_id', sa.String(), nullable=True), sa.Column('activity_object_ap_id', sa.String(), nullable=True),
sa.Column('visibility', sa.Enum('PUBLIC', 'UNLISTED', 'FOLLOWERS_ONLY', 'DIRECT', name='visibilityenum'), nullable=False), sa.Column('visibility', sa.Enum('PUBLIC', 'UNLISTED', 'FOLLOWERS_ONLY', 'DIRECT', name='visibilityenum'), nullable=False),
sa.Column('undo_id', sa.Integer(), nullable=False),
sa.Column('is_deleted', sa.Boolean(), nullable=False),
sa.Column('likes_count', sa.Integer(), nullable=False), sa.Column('likes_count', sa.Integer(), nullable=False),
sa.Column('announces_count', sa.Integer(), nullable=False), sa.Column('announces_count', sa.Integer(), nullable=False),
sa.Column('replies_count', sa.Integer(), nullable=False), sa.Column('replies_count', sa.Integer(), nullable=False),
@ -65,6 +68,7 @@ def upgrade() -> None:
sa.Column('relates_to_outbox_object_id', sa.Integer(), nullable=True), sa.Column('relates_to_outbox_object_id', sa.Integer(), nullable=True),
sa.Column('relates_to_actor_id', sa.Integer(), nullable=True), sa.Column('relates_to_actor_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['relates_to_actor_id'], ['actor.id'], ), sa.ForeignKeyConstraint(['relates_to_actor_id'], ['actor.id'], ),
sa.ForeignKeyConstraint(['undo_id'], ['outbox.id'], ),
sa.ForeignKeyConstraint(['relates_to_inbox_object_id'], ['inbox.id'], ), sa.ForeignKeyConstraint(['relates_to_inbox_object_id'], ['inbox.id'], ),
sa.ForeignKeyConstraint(['relates_to_outbox_object_id'], ['outbox.id'], ), sa.ForeignKeyConstraint(['relates_to_outbox_object_id'], ['outbox.id'], ),
sa.PrimaryKeyConstraint('id') sa.PrimaryKeyConstraint('id')

View file

@ -66,6 +66,7 @@ class InboxObject(Base):
visibility = Column(Enum(ap.VisibilityEnum), nullable=False) visibility = Column(Enum(ap.VisibilityEnum), nullable=False)
undo_id = Column(Integer, ForeignKey("inbox.id"), nullable=True) undo_id = Column(Integer, ForeignKey("inbox.id"), nullable=True)
is_deleted = Column(Boolean, nullable=False, default=False)
relates_to_inbox_object_id = Column( relates_to_inbox_object_id = Column(
Integer, Integer,
ForeignKey("inbox.id"), ForeignKey("inbox.id"),
@ -107,6 +108,8 @@ class OutboxObject(Base):
visibility = Column(Enum(ap.VisibilityEnum), nullable=False) visibility = Column(Enum(ap.VisibilityEnum), nullable=False)
undo_id = Column(Integer, ForeignKey("inbox.id"), nullable=True)
is_deleted = Column(Boolean, nullable=False, default=False)
likes_count = Column(Integer, nullable=False, default=0) likes_count = Column(Integer, nullable=False, default=0)
announces_count = Column(Integer, nullable=False, default=0) announces_count = Column(Integer, nullable=False, default=0)
replies_count: Mapped[int] = Column(Integer, nullable=False, default=0) #type: ignore replies_count: Mapped[int] = Column(Integer, nullable=False, default=0) #type: ignore