"""add courier online offline toggle

Revision ID: 6a8d1bc6e52d
Revises: 18830e0b291f
Create Date: 2026-07-17 11:35:54.910030

"""

from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = "6a8d1bc6e52d"
down_revision: Union[str, None] = "18830e0b291f"
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! ###
    # NOTE: autogenerate also proposed op.drop_table('spatial_ref_sys') (a
    # PostGIS system table — dropping it would break PostGIS entirely) and
    # dropping refresh_tokens_token_hash_key/users_phone_key (pre-existing
    # unique-index-vs-named-constraint drift unrelated to this migration).
    # Both removed by hand — same drift called out in 42828b3f2eea. Also
    # added server_default so any existing courier_profiles rows backfill
    # to offline rather than failing the NOT NULL add.
    op.add_column(
        "courier_profiles",
        sa.Column("is_online", sa.Boolean(), nullable=False, server_default=sa.false()),
    )
    op.alter_column("courier_profiles", "is_online", server_default=None)
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column("courier_profiles", "is_online")
    # ### end Alembic commands ###
