pyfedi/migrations/versions/03258111eef1_downvote_accept_mode.py

41 lines
1.2 KiB
Python

"""downvote accept mode
Revision ID: 03258111eef1
Revises: 9df13396fd54
Create Date: 2025-01-11 11:32:54.226698
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '03258111eef1'
down_revision = '9df13396fd54'
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.add_column(sa.Column('downvote_accept_mode', sa.Integer(), nullable=True))
with op.batch_alter_table('community', schema=None) as batch_op:
batch_op.execute('UPDATE "community" SET downvote_accept_mode = 0')
with op.batch_alter_table('instance', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_instance_trusted'), ['trusted'], unique=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('instance', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_instance_trusted'))
with op.batch_alter_table('community', schema=None) as batch_op:
batch_op.drop_column('downvote_accept_mode')
# ### end Alembic commands ###