"""add_order_banner_model

Revision ID: 31f18de7e03e
Revises: 471f6f4d3445
Create Date: 2025-08-05 13:55:23.300623

"""

from alembic import op
import sqlalchemy as sa

# revision identifiers, used by Alembic.
revision = "31f18de7e03e"
down_revision = "471f6f4d3445"
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "order_banner_info",
        sa.Column("id", sa.BIGINT(), autoincrement=True, nullable=False),
        sa.Column(
            "banner_id", sa.String(length=36), nullable=False, comment="Banner ID"
        ),
        sa.Column(
            "course_id", sa.String(length=36), nullable=False, comment="Course ID"
        ),
        sa.Column("show_banner", sa.Integer(), nullable=False, comment="Show banner"),
        sa.Column(
            "show_lesson_banner",
            sa.Integer(),
            nullable=False,
            comment="Show lesson banner",
        ),
        sa.Column(
            "deleted",
            sa.SmallInteger(),
            nullable=False,
            comment="Deletion flag: 0=active, 1=deleted",
        ),
        sa.Column(
            "created_at", sa.DateTime(), nullable=False, comment="Creation timestamp"
        ),
        sa.Column(
            "created_user_bid",
            sa.String(length=32),
            nullable=False,
            comment="Creator user business identifier",
        ),
        sa.Column(
            "updated_at", sa.DateTime(), nullable=False, comment="Last update timestamp"
        ),
        sa.Column(
            "updated_user_bid",
            sa.String(length=32),
            nullable=False,
            comment="Last updater user business identifier",
        ),
        sa.PrimaryKeyConstraint("id"),
    )
    with op.batch_alter_table("order_banner_info", schema=None) as batch_op:
        batch_op.create_index(
            batch_op.f("ix_order_banner_info_banner_id"), ["banner_id"], unique=False
        )
        batch_op.create_index(
            batch_op.f("ix_order_banner_info_course_id"), ["course_id"], unique=False
        )


def downgrade():
    with op.batch_alter_table("order_banner_info", schema=None) as batch_op:
        batch_op.drop_index(batch_op.f("ix_order_banner_info_course_id"))
        batch_op.drop_index(batch_op.f("ix_order_banner_info_banner_id"))

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