misp-modules/website/migrations/versions/c0e243696052_.py

46 lines
1.3 KiB
Python

"""empty message
Revision ID: c0e243696052
Revises: 1d38ae8361a7
Create Date: 2024-02-07 11:59:20.615266
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.exc import OperationalError
# revision identifiers, used by Alembic.
revision = 'c0e243696052'
down_revision = '1d38ae8361a7'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
try:
with op.batch_alter_table('session_db', schema=None) as batch_op:
batch_op.add_column(sa.Column('query_enter', sa.String(), nullable=True))
except OperationalError:
print("Column 'query_entry' already exist in 'session_db'")
try:
with op.batch_alter_table('session_db', schema=None) as batch_op:
batch_op.drop_column('query')
except OperationalError:
print("Column 'query' already dropped from 'session_db'")
except KeyError:
print("Column 'query' already dropped from 'session_db'")
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('session_db', schema=None) as batch_op:
batch_op.add_column(sa.Column('query', sa.VARCHAR(), nullable=True))
batch_op.drop_column('query_enter')
# ### end Alembic commands ###