"""backfill superuser flag for seeded admin

Revision ID: 20260714_0005
Revises: 20260714_0004
Create Date: 2026-07-14 14:00:00
"""

from typing import Sequence, Union

import sqlalchemy as sa
from alembic import op

revision: str = "20260714_0005"
down_revision: Union[str, None] = "20260714_0004"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    op.execute(
        sa.text(
            "UPDATE users SET is_superuser = true "
            "WHERE email = 'admin@compton.example' AND role = 'admin'"
        )
    )
    op.execute(
        sa.text(
            "UPDATE users SET is_superuser = false "
            "WHERE email IN ('ops@compton.example', 'user@compton.example')"
        )
    )


def downgrade() -> None:
    pass
