42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
"""add remark to license
|
|
|
|
Revision ID: 20251128_add_remark_to_license
|
|
Revises: abcd1236_add_image_path_to_product
|
|
Create Date: 2025-11-28 18:20:00.000000
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
from sqlalchemy import text
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = '20251128_add_remark_to_license'
|
|
down_revision = 'abcd1236_add_image_path_to_product'
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
# 检查字段是否已存在
|
|
conn = op.get_bind()
|
|
inspector = sa.inspect(conn)
|
|
columns = [col['name'] for col in inspector.get_columns('license')]
|
|
|
|
if 'remark' not in columns:
|
|
with op.batch_alter_table('license', schema=None) as batch_op:
|
|
batch_op.add_column(sa.Column('remark', sa.Text(), nullable=True))
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
# 检查字段是否存在
|
|
conn = op.get_bind()
|
|
inspector = sa.inspect(conn)
|
|
columns = [col['name'] for col in inspector.get_columns('license')]
|
|
|
|
if 'remark' in columns:
|
|
with op.batch_alter_table('license', schema=None) as batch_op:
|
|
batch_op.drop_column('remark')
|
|
# ### end Alembic commands ### |