pyfedi/migrations/versions/1a9507704262_add_user_deleted_and_indexes.py
2023-08-05 21:26:24 +12:00

56 lines
2 KiB
Python

"""add user.deleted and indexes
Revision ID: 1a9507704262
Revises: 54f1dd40e066
Create Date: 2023-08-05 21:09:39.158879
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '1a9507704262'
down_revision = '54f1dd40e066'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('community', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_community_ap_id'), ['ap_id'], unique=False)
batch_op.create_index(batch_op.f('ix_community_name'), ['name'], unique=False)
with op.batch_alter_table('post', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_post_ap_id'), ['ap_id'], unique=False)
with op.batch_alter_table('post_reply', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_post_reply_ap_id'), ['ap_id'], unique=False)
with op.batch_alter_table('user', schema=None) as batch_op:
batch_op.add_column(sa.Column('deleted', sa.Boolean(), nullable=True))
batch_op.create_index(batch_op.f('ix_user_ap_id'), ['ap_id'], unique=False)
batch_op.create_index(batch_op.f('ix_user_last_seen'), ['last_seen'], unique=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('user', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_user_last_seen'))
batch_op.drop_index(batch_op.f('ix_user_ap_id'))
batch_op.drop_column('deleted')
with op.batch_alter_table('post_reply', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_post_reply_ap_id'))
with op.batch_alter_table('post', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_post_ap_id'))
with op.batch_alter_table('community', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_community_name'))
batch_op.drop_index(batch_op.f('ix_community_ap_id'))
# ### end Alembic commands ###