pyfedi/migrations/versions/5e84668d279e_soft_deletes.py

46 lines
1.4 KiB
Python
Raw Permalink Normal View History

"""soft deletes
Revision ID: 5e84668d279e
Revises: 2191fa36c09d
Create Date: 2024-06-02 14:50:17.295862
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '5e84668d279e'
down_revision = '2191fa36c09d'
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', sa.Boolean(), nullable=True))
batch_op.create_index(batch_op.f('ix_post_deleted'), ['deleted'], unique=False)
with op.batch_alter_table('post_reply', schema=None) as batch_op:
batch_op.add_column(sa.Column('deleted', sa.Boolean(), nullable=True))
batch_op.create_index(batch_op.f('ix_post_reply_deleted'), ['deleted'], unique=False)
op.execute(sa.DDL('UPDATE "post" SET deleted = false'))
op.execute(sa.DDL('UPDATE "post_reply" SET deleted = false'))
# ### 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_index(batch_op.f('ix_post_reply_deleted'))
batch_op.drop_column('deleted')
with op.batch_alter_table('post', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_post_deleted'))
batch_op.drop_column('deleted')
# ### end Alembic commands ###