pyfedi/migrations/versions/7fc066ad475a_deleted_by.py

50 lines
1.7 KiB
Python

"""deleted_by
Revision ID: 7fc066ad475a
Revises: 238d7c60d676
Create Date: 2024-10-14 12:28:51.315599
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '7fc066ad475a'
down_revision = '238d7c60d676'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('post', schema=None) as batch_op:
batch_op.add_column(sa.Column('deleted_by', sa.Integer(), nullable=True))
batch_op.create_index(batch_op.f('ix_post_deleted_by'), ['deleted_by'], unique=False)
with op.batch_alter_table('post_reply', schema=None) as batch_op:
batch_op.add_column(sa.Column('deleted_by', sa.Integer(), nullable=True))
batch_op.create_index(batch_op.f('ix_post_reply_deleted_by'), ['deleted_by'], unique=False)
with op.batch_alter_table('user', schema=None) as batch_op:
batch_op.add_column(sa.Column('deleted_by', sa.Integer(), nullable=True))
batch_op.create_index(batch_op.f('ix_user_deleted_by'), ['deleted_by'], 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_deleted_by'))
batch_op.drop_column('deleted_by')
with op.batch_alter_table('post_reply', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_post_reply_deleted_by'))
batch_op.drop_column('deleted_by')
with op.batch_alter_table('post', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_post_deleted_by'))
batch_op.drop_column('deleted_by')
# ### end Alembic commands ###