pyfedi/migrations/versions/a88efa63415b_sub_topics.py
2024-03-01 20:32:29 +13:00

42 lines
1.4 KiB
Python

"""sub topics
Revision ID: a88efa63415b
Revises: 2629cf0e2965
Create Date: 2024-03-01 19:18:49.137449
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy_searchable import sync_trigger, drop_trigger
# revision identifiers, used by Alembic.
revision = 'a88efa63415b'
down_revision = '2629cf0e2965'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('topic', schema=None) as batch_op:
batch_op.add_column(sa.Column('parent_id', sa.Integer(), nullable=True))
conn = op.get_bind()
sync_trigger(conn, 'community', 'search_vector', ['name', 'title', 'description', 'rules'])
sync_trigger(conn, 'user', 'search_vector', ['user_name', 'about', 'keywords'])
sync_trigger(conn, 'post', 'search_vector', ['title', 'body'])
sync_trigger(conn, 'post_reply', 'search_vector', ['body'])
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('topic', schema=None) as batch_op:
batch_op.drop_column('parent_id')
conn = op.get_bind()
drop_trigger(conn, 'community', 'search_vector')
drop_trigger(conn, 'user', 'search_vector')
drop_trigger(conn, 'post', 'search_vector')
drop_trigger(conn, 'post_reply', 'search_vector')
# ### end Alembic commands ###