"""update mysql to migrate version

Revision ID: bd4a3ef686c3
Revises: ca7e9533368b
Create Date: 2025-08-17 07:59:57.174693

"""

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

# revision identifiers, used by Alembic.
revision = "bd4a3ef686c3"
down_revision = "ca7e9533368b"
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table("active_user_record", schema=None) as batch_op:
        batch_op.alter_column(
            "updated",
            existing_type=mysql.TIMESTAMP(),
            comment="Update time",
            existing_nullable=False,
        )

    with op.batch_alter_table("ai_course", schema=None) as batch_op:
        batch_op.alter_column(
            "updated",
            existing_type=mysql.TIMESTAMP(),
            comment="Update time",
            existing_nullable=False,
        )

    with op.batch_alter_table("ai_course_auth", schema=None) as batch_op:
        batch_op.alter_column(
            "updated_at",
            existing_type=mysql.TIMESTAMP(),
            comment="Update time",
            existing_nullable=False,
        )

    with op.batch_alter_table("ai_course_buy_record", schema=None) as batch_op:
        batch_op.alter_column(
            "updated",
            existing_type=mysql.TIMESTAMP(),
            comment="Update time",
            existing_nullable=False,
        )

    with op.batch_alter_table("ai_course_lesson_attend", schema=None) as batch_op:
        batch_op.alter_column(
            "updated",
            existing_type=mysql.TIMESTAMP(),
            comment="Update time",
            existing_nullable=False,
        )

    with op.batch_alter_table("ai_course_lesson_attendscript", schema=None) as batch_op:
        batch_op.alter_column(
            "updated",
            existing_type=mysql.TIMESTAMP(),
            comment="Update time",
            existing_nullable=False,
        )

    with op.batch_alter_table("ai_lesson", schema=None) as batch_op:
        batch_op.alter_column(
            "updated",
            existing_type=mysql.TIMESTAMP(),
            comment="Update time",
            existing_nullable=False,
        )

    with op.batch_alter_table("ai_lesson_script", schema=None) as batch_op:
        batch_op.alter_column(
            "updated",
            existing_type=mysql.TIMESTAMP(),
            comment="Update time",
            existing_nullable=False,
        )

    with op.batch_alter_table("discount_record", schema=None) as batch_op:
        batch_op.alter_column(
            "updated",
            existing_type=mysql.TIMESTAMP(),
            comment="Update time",
            existing_nullable=False,
        )

    with op.batch_alter_table("pingxx_order", schema=None) as batch_op:
        batch_op.alter_column(
            "updated",
            existing_type=mysql.TIMESTAMP(),
            comment="Update time",
            existing_nullable=False,
        )

    with op.batch_alter_table("risk_control_result", schema=None) as batch_op:
        batch_op.alter_column(
            "updated",
            existing_type=mysql.TIMESTAMP(),
            comment="Update time",
            existing_nullable=False,
        )

    with op.batch_alter_table("user_conversion", schema=None) as batch_op:
        batch_op.alter_column(
            "updated",
            existing_type=mysql.TIMESTAMP(),
            comment="Update time",
            existing_nullable=False,
        )

    with op.batch_alter_table("user_feedback", schema=None) as batch_op:
        batch_op.alter_column(
            "updated",
            existing_type=mysql.TIMESTAMP(),
            comment="Update time",
            existing_nullable=False,
        )

    with op.batch_alter_table("user_info", schema=None) as batch_op:
        batch_op.alter_column(
            "updated",
            existing_type=mysql.TIMESTAMP(),
            comment="Update time",
            existing_nullable=False,
        )

    with op.batch_alter_table("user_profile", schema=None) as batch_op:
        batch_op.alter_column(
            "updated",
            existing_type=mysql.TIMESTAMP(),
            comment="Update time",
            existing_nullable=False,
        )

    with op.batch_alter_table("user_token", schema=None) as batch_op:
        batch_op.alter_column(
            "updated",
            existing_type=mysql.TIMESTAMP(),
            comment="Update time",
            existing_nullable=False,
        )

    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table("user_token", schema=None) as batch_op:
        batch_op.alter_column(
            "updated",
            existing_type=mysql.TIMESTAMP(),
            comment=None,
            existing_comment="Update time",
            existing_nullable=False,
        )

    with op.batch_alter_table("user_profile", schema=None) as batch_op:
        batch_op.alter_column(
            "updated",
            existing_type=mysql.TIMESTAMP(),
            comment=None,
            existing_comment="Update time",
            existing_nullable=False,
        )

    with op.batch_alter_table("user_info", schema=None) as batch_op:
        batch_op.alter_column(
            "updated",
            existing_type=mysql.TIMESTAMP(),
            comment=None,
            existing_comment="Update time",
            existing_nullable=False,
        )

    with op.batch_alter_table("user_feedback", schema=None) as batch_op:
        batch_op.alter_column(
            "updated",
            existing_type=mysql.TIMESTAMP(),
            comment=None,
            existing_comment="Update time",
            existing_nullable=False,
        )

    with op.batch_alter_table("user_conversion", schema=None) as batch_op:
        batch_op.alter_column(
            "updated",
            existing_type=mysql.TIMESTAMP(),
            comment=None,
            existing_comment="Update time",
            existing_nullable=False,
        )

    with op.batch_alter_table("risk_control_result", schema=None) as batch_op:
        batch_op.alter_column(
            "updated",
            existing_type=mysql.TIMESTAMP(),
            comment=None,
            existing_comment="Update time",
            existing_nullable=False,
        )

    with op.batch_alter_table("pingxx_order", schema=None) as batch_op:
        batch_op.alter_column(
            "updated",
            existing_type=mysql.TIMESTAMP(),
            comment=None,
            existing_comment="Update time",
            existing_nullable=False,
        )

    with op.batch_alter_table("discount_record", schema=None) as batch_op:
        batch_op.alter_column(
            "updated",
            existing_type=mysql.TIMESTAMP(),
            comment=None,
            existing_comment="Update time",
            existing_nullable=False,
        )

    with op.batch_alter_table("discount", schema=None) as batch_op:
        batch_op.alter_column(
            "updated",
            existing_type=mysql.TIMESTAMP(),
            server_default=sa.text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"),
            existing_comment="Update time",
            existing_nullable=False,
        )

    with op.batch_alter_table("ai_lesson_script", schema=None) as batch_op:
        batch_op.alter_column(
            "updated",
            existing_type=mysql.TIMESTAMP(),
            comment=None,
            existing_comment="Update time",
            existing_nullable=False,
        )

    with op.batch_alter_table("ai_lesson", schema=None) as batch_op:
        batch_op.alter_column(
            "updated",
            existing_type=mysql.TIMESTAMP(),
            comment=None,
            existing_comment="Update time",
            existing_nullable=False,
        )

    with op.batch_alter_table("ai_course_lesson_attendscript", schema=None) as batch_op:
        batch_op.alter_column(
            "updated",
            existing_type=mysql.TIMESTAMP(),
            comment=None,
            existing_comment="Update time",
            existing_nullable=False,
        )

    with op.batch_alter_table("ai_course_lesson_attend", schema=None) as batch_op:
        batch_op.alter_column(
            "updated",
            existing_type=mysql.TIMESTAMP(),
            comment=None,
            existing_comment="Update time",
            existing_nullable=False,
        )

    with op.batch_alter_table("ai_course_buy_record", schema=None) as batch_op:
        batch_op.alter_column(
            "updated",
            existing_type=mysql.TIMESTAMP(),
            comment=None,
            existing_comment="Update time",
            existing_nullable=False,
        )

    with op.batch_alter_table("ai_course_auth", schema=None) as batch_op:
        batch_op.alter_column(
            "updated_at",
            existing_type=mysql.TIMESTAMP(),
            comment=None,
            existing_comment="Update time",
            existing_nullable=False,
        )

    with op.batch_alter_table("ai_course", schema=None) as batch_op:
        batch_op.alter_column(
            "updated",
            existing_type=mysql.TIMESTAMP(),
            comment=None,
            existing_comment="Update time",
            existing_nullable=False,
        )

    with op.batch_alter_table("active_user_record", schema=None) as batch_op:
        batch_op.alter_column(
            "updated",
            existing_type=mysql.TIMESTAMP(),
            comment=None,
            existing_comment="Update time",
            existing_nullable=False,
        )

    with op.batch_alter_table("active", schema=None) as batch_op:
        batch_op.alter_column(
            "updated",
            existing_type=mysql.TIMESTAMP(),
            server_default=sa.text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"),
            existing_comment="Update time",
            existing_nullable=False,
        )

    # ### end Alembic commands ###
