"""add active table

Revision ID: c3f101bbb462
Revises: a4d68cce5ce6
Create Date: 2025-11-13 06:07:34.199549

"""

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

# revision identifiers, used by Alembic.
revision = "c3f101bbb462"
down_revision = "a4d68cce5ce6"
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "active",
        sa.Column(
            "id",
            mysql.BIGINT(),
            autoincrement=True,
            nullable=False,
            comment="Unique ID",
        ),
        sa.Column(
            "active_id", sa.String(length=36), nullable=False, comment="Active UUID"
        ),
        sa.Column(
            "active_name", sa.String(length=255), nullable=False, comment="Active name"
        ),
        sa.Column(
            "active_desc", sa.Text(), nullable=False, comment="Active description"
        ),
        sa.Column("active_type", sa.Integer(), nullable=False, comment="Active type"),
        sa.Column(
            "active_join_type", sa.Integer(), nullable=False, comment="Active join type"
        ),
        sa.Column(
            "active_status", sa.Integer(), nullable=False, comment="Active status"
        ),
        sa.Column(
            "active_start_time",
            sa.DateTime(),
            nullable=False,
            comment="Active start time",
        ),
        sa.Column(
            "active_end_time", sa.DateTime(), nullable=False, comment="Active end time"
        ),
        sa.Column(
            "active_price",
            sa.Numeric(precision=10, scale=2),
            nullable=False,
            comment="Active price",
        ),
        sa.Column(
            "active_discount",
            sa.Numeric(precision=10, scale=2),
            nullable=False,
            comment="Active discount",
        ),
        sa.Column(
            "active_discount_type",
            sa.Integer(),
            nullable=False,
            comment="Active discount type",
        ),
        sa.Column(
            "active_discount_desc",
            sa.Text(),
            nullable=False,
            comment="Active discount description",
        ),
        sa.Column("active_filter", sa.Text(), nullable=False, comment="Active filter"),
        sa.Column(
            "active_course",
            sa.String(length=36),
            nullable=False,
            comment="Active course",
        ),
        sa.Column("created", sa.TIMESTAMP(), nullable=False, comment="Creation time"),
        sa.Column("updated", sa.TIMESTAMP(), nullable=False, comment="Update time"),
        sa.PrimaryKeyConstraint("id"),
    )
    with op.batch_alter_table("active", schema=None) as batch_op:
        batch_op.create_index(
            batch_op.f("ix_active_active_end_time"), ["active_end_time"], unique=False
        )
        batch_op.create_index(
            batch_op.f("ix_active_active_start_time"),
            ["active_start_time"],
            unique=False,
        )
        batch_op.create_index(
            batch_op.f("ix_active_active_status"), ["active_status"], unique=False
        )


def downgrade():
    with op.batch_alter_table("active", schema=None) as batch_op:
        batch_op.drop_index(batch_op.f("ix_active_active_status"))
        batch_op.drop_index(batch_op.f("ix_active_active_start_time"))
        batch_op.drop_index(batch_op.f("ix_active_active_end_time"))

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