"""change db wrong typo of temprature to temperature

Revision ID: 9c4403dc2f1f
Revises: 88c0fd574bdd
Create Date: 2025-06-17 11:38:19.224326

"""

from alembic import op
import sqlalchemy as sa
from sqlalchemy import text

# revision identifiers, used by Alembic.
revision = "9c4403dc2f1f"
down_revision = "88c0fd574bdd"
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table("ai_course", schema=None) as batch_op:
        batch_op.add_column(
            sa.Column(
                "course_default_temperature",
                sa.DECIMAL(precision=10, scale=2),
                nullable=False,
                comment="Course default temperature",
            )
        )

    with op.batch_alter_table("ai_lesson", schema=None) as batch_op:
        batch_op.add_column(
            sa.Column(
                "lesson_default_temperature",
                sa.DECIMAL(precision=10, scale=2),
                nullable=False,
                comment="Lesson default temperature",
            )
        )

    with op.batch_alter_table("ai_lesson_script", schema=None) as batch_op:
        batch_op.add_column(
            sa.Column(
                "script_temperature",
                sa.DECIMAL(precision=10, scale=2),
                nullable=False,
                comment="Script Temperature",
            )
        )

    op.execute(
        text(
            "UPDATE ai_course set course_default_temperature = course_default_temprature"
        )
    )
    op.execute(
        text(
            "UPDATE ai_lesson set lesson_default_temperature = lesson_default_temprature"
        )
    )
    op.execute(
        text("UPDATE ai_lesson_script set script_temperature = script_temprature")
    )

    # ### end Alembic commands ###


def downgrade():
    with op.batch_alter_table("ai_lesson_script", schema=None) as batch_op:
        batch_op.drop_column("script_temperature")

    with op.batch_alter_table("ai_lesson", schema=None) as batch_op:
        batch_op.drop_column("lesson_default_temperature")

    with op.batch_alter_table("ai_course", schema=None) as batch_op:
        batch_op.drop_column("course_default_temperature")

    # ### end Alembic commands ###
