pyfedi/migrations/versions/86b6fd708bd0_index_all_the_things.py

77 lines
3.3 KiB
Python
Raw Normal View History

2024-01-24 21:17:36 +13:00
"""index all the things
Revision ID: 86b6fd708bd0
Revises: a4be1b198b0f
Create Date: 2024-01-24 21:17:10.102368
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '86b6fd708bd0'
down_revision = 'a4be1b198b0f'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('community_join_request', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_community_join_request_community_id'), ['community_id'], unique=False)
with op.batch_alter_table('filter', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_filter_user_id'), ['user_id'], unique=False)
with op.batch_alter_table('notification', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_notification_user_id'), ['user_id'], unique=False)
with op.batch_alter_table('post_reply_vote', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_post_reply_vote_post_reply_id'), ['post_reply_id'], unique=False)
batch_op.create_index(batch_op.f('ix_post_reply_vote_user_id'), ['user_id'], unique=False)
with op.batch_alter_table('post_vote', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_post_vote_post_id'), ['post_id'], unique=False)
batch_op.create_index(batch_op.f('ix_post_vote_user_id'), ['user_id'], unique=False)
with op.batch_alter_table('user_block', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_user_block_blocked_id'), ['blocked_id'], unique=False)
batch_op.create_index(batch_op.f('ix_user_block_blocker_id'), ['blocker_id'], unique=False)
with op.batch_alter_table('user_note', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_user_note_target_id'), ['target_id'], unique=False)
batch_op.create_index(batch_op.f('ix_user_note_user_id'), ['user_id'], unique=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('user_note', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_user_note_user_id'))
batch_op.drop_index(batch_op.f('ix_user_note_target_id'))
with op.batch_alter_table('user_block', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_user_block_blocker_id'))
batch_op.drop_index(batch_op.f('ix_user_block_blocked_id'))
with op.batch_alter_table('post_vote', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_post_vote_user_id'))
batch_op.drop_index(batch_op.f('ix_post_vote_post_id'))
with op.batch_alter_table('post_reply_vote', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_post_reply_vote_user_id'))
batch_op.drop_index(batch_op.f('ix_post_reply_vote_post_reply_id'))
with op.batch_alter_table('notification', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_notification_user_id'))
with op.batch_alter_table('filter', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_filter_user_id'))
with op.batch_alter_table('community_join_request', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_community_join_request_community_id'))
# ### end Alembic commands ###