"""Role payroll

Revision ID: a8e40ab24138
Revises: 02ed6e775351
Create Date: 2025-12-20 13:44:13.807704

"""

from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa
import sqlmodel
from sqlalchemy.dialects import postgresql

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


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column(
        "book",
        "status",
        existing_type=postgresql.ENUM(
            "active",
            "borrowed",
            "reserved",
            "restoration",
            "written_off",
            name="bookstatus",
        ),
        type_=sa.String(),
        existing_nullable=False,
        existing_server_default=sa.text("'active'::bookstatus"),
    )
    op.add_column("roles", sa.Column("payroll", sa.Integer(), nullable=False))
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column("roles", "payroll")
    op.alter_column(
        "book",
        "status",
        existing_type=sa.String(),
        type_=postgresql.ENUM(
            "active",
            "borrowed",
            "reserved",
            "restoration",
            "written_off",
            name="bookstatus",
        ),
        existing_nullable=False,
        existing_server_default=sa.text("'active'::bookstatus"),
    )
    # ### end Alembic commands ###
