"""CHUNITHM VERSE support

Revision ID: 49c295e89cd4
Revises: 7070a6fa8cdc
Create Date: 2025-03-09 14:10:03.067328

"""

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

# revision identifiers, used by Alembic.
revision = "49c295e89cd4"
down_revision = "7070a6fa8cdc"
branch_labels = None
depends_on = None


def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column("chuni_profile_data", sa.Column("trophyIdSub1", sa.Integer()))
    op.add_column("chuni_profile_data", sa.Column("trophyIdSub2", sa.Integer()))
    op.add_column("chuni_score_playlog", sa.Column("monthPoint", sa.Integer()))
    op.add_column("chuni_score_playlog", sa.Column("eventPoint", sa.Integer()))

    op.create_table(
        "chuni_static_unlock_challenge",
        sa.Column("id", sa.Integer(), primary_key=True, nullable=False),
        sa.Column("version", sa.Integer(), nullable=False),
        sa.Column("unlockChallengeId", sa.Integer(), nullable=False),
        sa.Column("name", sa.String(length=255)),
        sa.Column("isEnabled", sa.Boolean(), server_default="1"),
        sa.Column("startDate", sa.TIMESTAMP(), server_default=func.now()),
        sa.Column("courseId1", sa.Integer()),
        sa.Column("courseId2", sa.Integer()),
        sa.Column("courseId3", sa.Integer()),
        sa.Column("courseId4", sa.Integer()),
        sa.Column("courseId5", sa.Integer()),
        sa.UniqueConstraint(
            "version", "unlockChallengeId", name="chuni_static_unlock_challenge_uk"
        ),
        mysql_charset="utf8mb4",
    )

    op.create_table(
        "chuni_item_unlock_challenge",
        sa.Column("id", sa.Integer(), primary_key=True, nullable=False),
        sa.Column("version", sa.Integer(), nullable=False),
        sa.Column(
            "user",
            sa.Integer(),
            sa.ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"),
            nullable=False,
        ),
        sa.Column("unlockChallengeId", sa.Integer(), nullable=False),
        sa.Column("status", sa.Integer()),
        sa.Column("clearCourseId", sa.Integer()),
        sa.Column("conditionType", sa.Integer()),
        sa.Column("score", sa.Integer()),
        sa.Column("life", sa.Integer()),
        sa.Column("clearDate", sa.TIMESTAMP(), server_default=func.now()),
        sa.UniqueConstraint(
            "version",
            "user",
            "unlockChallengeId",
            name="chuni_item_unlock_challenge_uk",
        ),
        mysql_charset="utf8mb4",
    )

    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column("chuni_score_playlog", "eventPoint")
    op.drop_column("chuni_score_playlog", "monthPoint")
    op.drop_column("chuni_profile_data", "trophyIdSub2")
    op.drop_column("chuni_profile_data", "trophyIdSub1")

    op.drop_table("chuni_static_unlock_challenge")
    op.drop_table("chuni_item_unlock_challenge")
    # ### end Alembic commands ###
