"""Add lockdown mode

Revision ID: a66a525f44f3
Revises: e92812b07fe8
Create Date: 2026-02-10 09:23:42.676255

"""

from typing import Sequence, Union

import sqlalchemy as sa

from alembic import op  # type: ignore[attr-defined]

# revision identifiers, used by Alembic.
revision: str = "a66a525f44f3"
down_revision: Union[str, Sequence[str], None] = "e92812b07fe8"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    """Upgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    companytype_enum = sa.Enum(
        "Normal", "Maintenance", "Lockdown", name="robotstartupmode", create_type=False
    )
    companytype_enum.create(op.get_bind(), checkfirst=True)

    op.add_column(
        "persistent_robot_state",
        sa.Column(
            "robot_startup_mode",
            companytype_enum,
            nullable=False,
            server_default="Normal",
        ),
    )
    op.drop_column("persistent_robot_state", "is_maintenance_mode")
    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column(
        "persistent_robot_state",
        sa.Column(
            "is_maintenance_mode", sa.BOOLEAN(), autoincrement=False, nullable=False
        ),
    )
    op.drop_column("persistent_robot_state", "robot_startup_mode")
    # ### end Alembic commands ###
