From 2457a85564307149f6ae862ff9a673eebfb6dddd Mon Sep 17 00:00:00 2001 From: southfox Date: Thu, 16 Mar 2023 17:41:07 +0800 Subject: [PATCH] alembic/update database models --- alembic/versions/2022_11_22_1613-f68634d9bba2_init.py | 4 ++++ app/models.py | 4 +++- data/.gitignore | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/alembic/versions/2022_11_22_1613-f68634d9bba2_init.py b/alembic/versions/2022_11_22_1613-f68634d9bba2_init.py index 1b27407..b1d81e9 100644 --- a/alembic/versions/2022_11_22_1613-f68634d9bba2_init.py +++ b/alembic/versions/2022_11_22_1613-f68634d9bba2_init.py @@ -26,6 +26,8 @@ def upgrade() -> None: sa.Column('ap_actor', sa.String(), nullable=False), sa.Column('is_blocked', sa.Boolean(), server_default='0', nullable=False), sa.Column('is_deleted', sa.Boolean(), server_default='0', nullable=False), + sa.Column('ap_type', sa.String(), nullable=False), + sa.Column('handle', sa.String(), nullable=True), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_actor_ap_id'), 'actor', ['ap_id'], unique=True) @@ -39,6 +41,7 @@ def upgrade() -> None: ) op.create_index(op.f('ix_ingress_ap_id'), 'ingress', ['ap_id'], unique=False) op.create_index(op.f('ix_ingress_id'), 'ingress', ['id'], unique=False) + op.create_index(op.f('ix_actor_handle'), 'actor', ['handle'], unique=False) # ### end Alembic commands ### @@ -49,5 +52,6 @@ def downgrade() -> None: op.drop_table('ingress') op.drop_index(op.f('ix_actor_id'), table_name='actor') op.drop_index(op.f('ix_actor_ap_id'), table_name='actor') + op.drop_index(op.f('ix_actor_handle'), table_name='actor') op.drop_table('actor') # ### end Alembic commands ### diff --git a/app/models.py b/app/models.py index af135cf..a0e9271 100644 --- a/app/models.py +++ b/app/models.py @@ -32,7 +32,9 @@ class Actor(Base): ap_id: Mapped[str] = Column(String, unique=True, nullable=False, index=True) # type: ignore ap_actor = Column(JSON, nullable=False) - ap_actor = Column(String, nullable=False) + ap_type = Column(String, nullable=False) + + handle = Column(String, nullable=True, index=True) is_blocked = Column(Boolean, nullable=False, default=False, server_default="0") is_deleted = Column(Boolean, nullable=False, default=False, server_default="0") diff --git a/data/.gitignore b/data/.gitignore index b39747b..a8e3a4c 100644 --- a/data/.gitignore +++ b/data/.gitignore @@ -4,6 +4,7 @@ tmp/ config.toml *.pem +*.db *.py[cod] *.egg