pyfedi/migrations/versions/8758c0a94f82_defederation_subscription.py
2024-12-27 20:20:16 +13:00

48 lines
1.8 KiB
Python

"""defederation subscription
Revision ID: 8758c0a94f82
Revises: f961f446ae17
Create Date: 2024-12-27 16:47:08.097093
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '8758c0a94f82'
down_revision = 'f961f446ae17'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('defederation_subscription',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('domain', sa.String(length=256), nullable=True),
sa.PrimaryKeyConstraint('id')
)
with op.batch_alter_table('defederation_subscription', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_defederation_subscription_domain'), ['domain'], unique=False)
with op.batch_alter_table('banned_instances', schema=None) as batch_op:
batch_op.add_column(sa.Column('subscription_id', sa.Integer(), nullable=True))
batch_op.create_index(batch_op.f('ix_banned_instances_subscription_id'), ['subscription_id'], unique=False)
batch_op.create_foreign_key(None, 'defederation_subscription', ['subscription_id'], ['id'])
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('banned_instances', schema=None) as batch_op:
batch_op.drop_constraint(None, type_='foreignkey')
batch_op.drop_index(batch_op.f('ix_banned_instances_subscription_id'))
batch_op.drop_column('subscription_id')
with op.batch_alter_table('defederation_subscription', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_defederation_subscription_domain'))
op.drop_table('defederation_subscription')
# ### end Alembic commands ###