Switch to batch operations for SQL migration

This commit is contained in:
Joshua Elson 2024-03-20 15:01:59 -05:00
parent 8e8535cbe9
commit 63ed03785b
No known key found for this signature in database
GPG Key ID: E58A168392A2536D
1 changed files with 10 additions and 8 deletions

View File

@ -14,13 +14,15 @@ from alembic import op
import sqlalchemy as sa
def upgrade():
op.add_column('ps_transports', sa.Column('tcp_keepalive_enable', sa.Boolean(), nullable=True))
op.add_column('ps_transports', sa.Column('tcp_keepalive_idle_time', sa.Integer(), nullable=True))
op.add_column('ps_transports', sa.Column('tcp_keepalive_interval_time', sa.Integer(), nullable=True))
op.add_column('ps_transports', sa.Column('tcp_keepalive_probe_count', sa.Integer(), nullable=True))
with op.batch_alter_table('ps_transports') as batch_op:
batch_op.add_column(sa.Column('tcp_keepalive_enable', sa.Boolean(), nullable=True))
batch_op.add_column(sa.Column('tcp_keepalive_idle_time', sa.Integer(), nullable=True))
batch_op.add_column(sa.Column('tcp_keepalive_interval_time', sa.Integer(), nullable=True))
batch_op.add_column(sa.Column('tcp_keepalive_probe_count', sa.Integer(), nullable=True))
def downgrade():
op.drop_column('ps_transports', 'tcp_keepalive_enable')
op.drop_column('ps_transports', 'tcp_keepalive_idle_time')
op.drop_column('ps_transports', 'tcp_keepalive_interval_time')
op.drop_column('ps_transports', 'tcp_keepalive_probe_count')
with op.batch_alter_table('ps_transports') as batch_op:
batch_op.drop_column('tcp_keepalive_enable')
batch_op.drop_column('tcp_keepalive_idle_time')
batch_op.drop_column('tcp_keepalive_interval_time')
batch_op.drop_column('tcp_keepalive_probe_count')