pyfedi/migrations/versions/20a3bae71dd7_banned_until.py
2024-11-30 09:50:14 +13:00

49 lines
1.6 KiB
Python

"""banned until
Revision ID: 20a3bae71dd7
Revises: d88b49617de0
Create Date: 2024-11-30 08:52:27.584637
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '20a3bae71dd7'
down_revision = 'd88b49617de0'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('instance_ban',
sa.Column('user_id', sa.Integer(), nullable=False),
sa.Column('instance_id', sa.Integer(), nullable=False),
sa.Column('banned_until', sa.DateTime(), nullable=True),
sa.ForeignKeyConstraint(['instance_id'], ['instance.id'], ),
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
sa.PrimaryKeyConstraint('user_id', 'instance_id')
)
with op.batch_alter_table('community_ban', schema=None) as batch_op:
batch_op.add_column(sa.Column('banned_until', sa.DateTime(), nullable=True))
with op.batch_alter_table('user', schema=None) as batch_op:
batch_op.add_column(sa.Column('banned_until', sa.DateTime(), nullable=True))
batch_op.create_index(batch_op.f('ix_user_banned'), ['banned'], 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_banned'))
batch_op.drop_column('banned_until')
with op.batch_alter_table('community_ban', schema=None) as batch_op:
batch_op.drop_column('banned_until')
op.drop_table('instance_ban')
# ### end Alembic commands ###