pyfedi/migrations/versions/e82f86c550ac_reply_depth.py

41 lines
1.3 KiB
Python
Raw Normal View History

2023-10-10 22:25:37 +13:00
"""reply depth
Revision ID: e82f86c550ac
Revises: 8c5cc19e0670
Create Date: 2023-10-10 20:51:09.662080
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'e82f86c550ac'
down_revision = '8c5cc19e0670'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('post_reply', schema=None) as batch_op:
batch_op.add_column(sa.Column('domain_id', sa.Integer(), nullable=True))
batch_op.add_column(sa.Column('depth', sa.Integer(), nullable=True))
batch_op.create_index(batch_op.f('ix_post_reply_domain_id'), ['domain_id'], unique=False)
batch_op.create_index(batch_op.f('ix_post_reply_ranking'), ['ranking'], unique=False)
batch_op.create_foreign_key(None, 'domain', ['domain_id'], ['id'])
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('post_reply', schema=None) as batch_op:
batch_op.drop_constraint(None, type_='foreignkey')
batch_op.drop_index(batch_op.f('ix_post_reply_ranking'))
batch_op.drop_index(batch_op.f('ix_post_reply_domain_id'))
batch_op.drop_column('depth')
batch_op.drop_column('domain_id')
# ### end Alembic commands ###