"""Scheduling activity log — nullable actor_id for system events (INDL-38)

The INDL-38 family-notification ARQ jobs (`send_scheduling_confirmation`,
`send_scheduling_reminder`) write `scheduling_activity_log` entries
(`confirmation_email_sent`, `reminder_email_sent`, `email_error`) with no human
actor — they run in the background worker, not on behalf of a logged-in user.
The original 0061 migration (service scheduling phase 2, renumbered from
0057 when develop was merged into this branch) declared `actor_id NOT
NULL`, which would reject every one of these system-originated rows. This
migration relaxes that constraint to nullable; all existing rows already
carry a non-null actor_id, so no backfill is required.

Chains off 0062 (scheduling week index, renumbered from 0058). Fully
reversible via downgrade() — provided no NULL actor_id rows exist at
downgrade time (true immediately after upgrade, and true again if the
notification jobs are disabled/removed first).
"""
from alembic import op
from sqlalchemy.dialects import postgresql

revision = "0063"
down_revision = "0062"
branch_labels = None
depends_on = None


def upgrade() -> None:
    op.alter_column(
        "scheduling_activity_log",
        "actor_id",
        existing_type=postgresql.UUID(as_uuid=True),
        nullable=True,
    )


def downgrade() -> None:
    op.alter_column(
        "scheduling_activity_log",
        "actor_id",
        existing_type=postgresql.UUID(as_uuid=True),
        nullable=False,
    )
