"""align PostgreSQL enum labels with Python enum values (lowercase)

Revision ID: 0003_fix_enum_values
Revises: 0002_user_mobile
Create Date: 2026-07-07
"""
from __future__ import annotations

from typing import Sequence, Union

from alembic import op

revision: str = "0003_fix_enum_values"
down_revision: Union[str, None] = "0002_user_mobile"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    op.execute("ALTER TYPE user_status RENAME VALUE 'ACTIVE' TO 'active'")
    op.execute("ALTER TYPE user_status RENAME VALUE 'INACTIVE' TO 'inactive'")
    op.execute("ALTER TYPE user_status RENAME VALUE 'SUSPENDED' TO 'suspended'")
    op.execute("ALTER TYPE membership_role RENAME VALUE 'TENANT_ADMIN' TO 'tenant_admin'")
    op.execute("ALTER TYPE membership_role RENAME VALUE 'TENANT_MEMBER' TO 'tenant_member'")


def downgrade() -> None:
    op.execute("ALTER TYPE membership_role RENAME VALUE 'tenant_member' TO 'TENANT_MEMBER'")
    op.execute("ALTER TYPE membership_role RENAME VALUE 'tenant_admin' TO 'TENANT_ADMIN'")
    op.execute("ALTER TYPE user_status RENAME VALUE 'suspended' TO 'SUSPENDED'")
    op.execute("ALTER TYPE user_status RENAME VALUE 'inactive' TO 'INACTIVE'")
    op.execute("ALTER TYPE user_status RENAME VALUE 'active' TO 'ACTIVE'")
