"""删除生成表的输入输出

Revision ID: dc1fbd112814
Revises: 5d2db654417b
Create Date: 2026-05-21 09:09:01.544128
"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = 'dc1fbd112814'
down_revision: Union[str, None] = '5d2db654417b'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None

def _has_column(table_name: str, column_name: str) -> bool:
    bind = op.get_bind()
    inspector = sa.inspect(bind)
    columns = inspector.get_columns(table_name)
    return any(col["name"] == column_name for col in columns)

def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    if _has_column('generation_records', 'request_data'):
        op.drop_column('generation_records', 'request_data')
    if _has_column('generation_records', 'response_data'):
        op.drop_column('generation_records', 'response_data')
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    if not _has_column('generation_records', 'response_data'):
        op.add_column('generation_records', sa.Column('response_data', sa.TEXT(), autoincrement=False, nullable=True))
    if not _has_column('generation_records', 'request_data'):
        op.add_column('generation_records', sa.Column('request_data', sa.TEXT(), autoincrement=False, nullable=True))
    # ### end Alembic commands ###
