pyfedi/migrations/versions/f6d6bd92cf88_post_microblog_flag.py

35 lines
898 B
Python
Raw Normal View History

"""post microblog flag
Revision ID: f6d6bd92cf88
Revises: 5bf49b8b7b79
Create Date: 2024-08-08 18:41:20.321882
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'f6d6bd92cf88'
down_revision = '5bf49b8b7b79'
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('microblog', sa.Boolean(), nullable=True))
# ### end Alembic commands ###
op.execute(sa.DDL("UPDATE \"post\" SET microblog = true WHERE starts_with(title, '[Microblog]')"))
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('post', schema=None) as batch_op:
batch_op.drop_column('microblog')
# ### end Alembic commands ###