"""update profile model

Revision ID: b4e38ed4754d
Revises: 831f9de41c8d
Create Date: 2025-04-09 05:13:08.801399

"""

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql

# revision identifiers, used by Alembic.
revision = "b4e38ed4754d"
down_revision = "831f9de41c8d"
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table("profile_item", schema=None) as batch_op:
        batch_op.add_column(
            sa.Column(
                "profile_raw_prompt",
                sa.Text(),
                nullable=False,
                comment="Profile raw prompt",
            )
        )
        batch_op.alter_column(
            "profile_type",
            existing_type=mysql.INTEGER(display_width=11),
            comment="",
            existing_nullable=False,
        )
        batch_op.alter_column(
            "profile_value_type",
            existing_type=mysql.INTEGER(display_width=11),
            comment="",
            existing_nullable=False,
        )
        batch_op.alter_column(
            "profile_show_type",
            existing_type=mysql.INTEGER(display_width=11),
            comment="",
            existing_nullable=False,
        )
        batch_op.alter_column(
            "profile_prompt_type",
            existing_type=mysql.INTEGER(display_width=11),
            comment="",
            existing_nullable=False,
        )

    with op.batch_alter_table("profile_item_i18n", schema=None) as batch_op:
        batch_op.alter_column(
            "conf_type",
            existing_type=mysql.INTEGER(display_width=11),
            comment="",
            existing_nullable=False,
        )

    with op.batch_alter_table("user_profile", schema=None) as batch_op:
        batch_op.alter_column(
            "profile_type",
            existing_type=mysql.INTEGER(display_width=11),
            comment="",
            existing_nullable=False,
            existing_server_default=sa.text("'0'"),
        )

    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table("user_profile", schema=None) as batch_op:
        batch_op.alter_column(
            "profile_type",
            existing_type=mysql.INTEGER(display_width=11),
            comment=None,
            existing_comment="",
            existing_nullable=False,
            existing_server_default=sa.text("'0'"),
        )

    with op.batch_alter_table("profile_item_i18n", schema=None) as batch_op:
        batch_op.alter_column(
            "conf_type",
            existing_type=mysql.INTEGER(display_width=11),
            comment=None,
            existing_comment="",
            existing_nullable=False,
        )

    with op.batch_alter_table("profile_item", schema=None) as batch_op:
        batch_op.alter_column(
            "profile_prompt_type",
            existing_type=mysql.INTEGER(display_width=11),
            comment=None,
            existing_comment="",
            existing_nullable=False,
        )
        batch_op.alter_column(
            "profile_show_type",
            existing_type=mysql.INTEGER(display_width=11),
            comment=None,
            existing_comment="",
            existing_nullable=False,
        )
        batch_op.alter_column(
            "profile_value_type",
            existing_type=mysql.INTEGER(display_width=11),
            comment=None,
            existing_comment="",
            existing_nullable=False,
        )
        batch_op.alter_column(
            "profile_type",
            existing_type=mysql.INTEGER(display_width=11),
            comment=None,
            existing_comment="",
            existing_nullable=False,
        )
        batch_op.drop_column("profile_raw_prompt")

    # ### end Alembic commands ###
