"""ai_course_auth

Revision ID: 79bafff21efb
Revises: bcf2a9657162
Create Date: 2025-05-09 08:08:22.617343

"""

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

# revision identifiers, used by Alembic.
revision = "79bafff21efb"
down_revision = "bcf2a9657162"
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "ai_course_auth",
        sa.Column("id", mysql.BIGINT(), autoincrement=True, nullable=False),
        sa.Column(
            "course_auth_id",
            sa.String(length=36),
            nullable=False,
            comment="course_auth_id UUID",
        ),
        sa.Column(
            "course_id", sa.String(length=36), nullable=False, comment="course_id UUID"
        ),
        sa.Column("user_id", sa.String(length=36), nullable=False, comment="User UUID"),
        sa.Column(
            "auth_type", sa.String(length=255), nullable=False, comment="auth_info"
        ),
        sa.Column("status", sa.Integer(), nullable=False, comment="Status"),
        sa.Column(
            "created_at",
            sa.TIMESTAMP(),
            nullable=False,
            comment="Creation time",
            server_default=sa.text("CURRENT_TIMESTAMP"),
        ),
        sa.Column(
            "updated_at",
            sa.TIMESTAMP(),
            nullable=False,
            comment="Update time",
            server_default=sa.text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"),
        ),
        sa.PrimaryKeyConstraint("id"),
    )
    with op.batch_alter_table("ai_course_auth", schema=None) as batch_op:
        batch_op.create_index(
            batch_op.f("ix_ai_course_auth_course_auth_id"),
            ["course_auth_id"],
            unique=False,
        )

    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table("ai_course_auth", schema=None) as batch_op:
        batch_op.drop_index(batch_op.f("ix_ai_course_auth_course_auth_id"))

    op.drop_table("ai_course_auth")
    # ### end Alembic commands ###
