"""CHUNITHM X-VERSE

Revision ID: 8b57e9646449
Revises: bdf710616ba4
Create Date: 2025-12-12 16:09:07.530809

"""

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "8b57e9646449"
down_revision = "bdf710616ba4"
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column(
        "chuni_profile_data",
        sa.Column("stageId", sa.Integer(), nullable=False, server_default="99999"),
    )
    op.create_table(
        "chuni_static_linked_verse",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("version", sa.Integer(), nullable=False),
        sa.Column("linkedVerseId", sa.Integer(), nullable=False),
        sa.Column("name", sa.String(length=255), nullable=True),
        sa.Column("isEnabled", sa.Boolean(), server_default="1", nullable=False),
        sa.Column(
            "startDate", sa.TIMESTAMP(), server_default=sa.text("now()"), nullable=True
        ),
        sa.Column("courseId1", sa.Integer(), nullable=True),
        sa.Column("courseId2", sa.Integer(), nullable=True),
        sa.Column("courseId3", sa.Integer(), nullable=True),
        sa.Column("courseId4", sa.Integer(), nullable=True),
        sa.Column("courseId5", sa.Integer(), nullable=True),
        sa.PrimaryKeyConstraint("id"),
        sa.UniqueConstraint(
            "version", "linkedVerseId", name="chuni_static_linked_verse_pk"
        ),
        mysql_charset="utf8mb4",
    )
    op.create_table(
        "chuni_item_linked_verse",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("user", sa.Integer(), nullable=False),
        sa.Column("linkedVerseId", sa.Integer(), nullable=False),
        sa.Column("progress", sa.String(length=255), nullable=True),
        sa.Column("statusOpen", sa.Integer(), nullable=True),
        sa.Column("statusUnlock", sa.Integer(), nullable=True),
        sa.Column("isFirstClear", sa.Integer(), nullable=True),
        sa.Column("numClear", sa.Integer(), nullable=True),
        sa.Column("clearCourseId", sa.Integer(), nullable=True),
        sa.Column("clearCourseLevel", sa.Integer(), nullable=True),
        sa.Column("clearScore", sa.Integer(), nullable=True),
        sa.Column("clearDate", sa.String(length=25), nullable=True),
        sa.Column("clearUserId1", sa.Integer(), nullable=True),
        sa.Column("clearUserId2", sa.Integer(), nullable=True),
        sa.Column("clearUserId3", sa.Integer(), nullable=True),
        sa.Column("clearUserName0", sa.String(length=20), nullable=True),
        sa.Column("clearUserName1", sa.String(length=20), nullable=True),
        sa.Column("clearUserName2", sa.String(length=20), nullable=True),
        sa.Column("clearUserName3", sa.String(length=20), nullable=True),
        sa.ForeignKeyConstraint(
            ["user"], ["aime_user.id"], onupdate="cascade", ondelete="cascade"
        ),
        sa.PrimaryKeyConstraint("id"),
        sa.UniqueConstraint("user", "linkedVerseId", name="chuni_item_linked_verse_uk"),
        mysql_charset="utf8mb4",
    )
    op.create_table(
        "chuni_static_stage",
        sa.Column("id", sa.Integer(), primary_key=True, nullable=False),
        sa.Column("version", sa.Integer(), nullable=False),
        sa.Column("stageId", sa.Integer(), nullable=False),
        sa.Column("name", sa.String(length=255)),
        sa.Column("imagePath", sa.String(length=255)),
        sa.Column("isEnabled", sa.Boolean(), server_default="1"),
        sa.Column("defaultHave", sa.Boolean(), server_default="0"),
        sa.Column("opt", sa.BIGINT(), sa.ForeignKey("chuni_static_opt.id", ondelete="SET NULL", onupdate="cascade")),
        sa.UniqueConstraint(
            "version", "stageId", name="chuni_static_stage_uk"
        ),
        mysql_charset="utf8mb4",
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column("chuni_profile_data", "stageId")
    op.drop_table("chuni_item_linked_verse")
    op.drop_table("chuni_static_linked_verse")
    op.drop_table("chuni_static_stage")
    # ### end Alembic commands ###
