misp-modules/website/migrations/versions/0c02b861944b_.py

46 lines
1.3 KiB
Python

"""empty message
Revision ID: 0c02b861944b
Revises: ef119b41c5f2
Create Date: 2024-02-06 09:08:59.802932
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.exc import OperationalError
# revision identifiers, used by Alembic.
revision = '0c02b861944b'
down_revision = 'ef119b41c5f2'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
try:
with op.batch_alter_table('module', schema=None) as batch_op:
batch_op.add_column(sa.Column('request_on_query', sa.Boolean(), nullable=True))
except OperationalError:
print("Column 'request_on_query' already exist in 'module'")
try:
with op.batch_alter_table('module__config', schema=None) as batch_op:
batch_op.drop_column('request_on_query')
except OperationalError:
print("Column 'request_on_query' already dropped from 'module__config'")
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('module__config', schema=None) as batch_op:
batch_op.add_column(sa.Column('request_on_query', sa.BOOLEAN(), nullable=True))
with op.batch_alter_table('module', schema=None) as batch_op:
batch_op.drop_column('request_on_query')
# ### end Alembic commands ###