"""Add email_aliases JSON to identity_persons. Revision ID: 057 Revises: 056 Create Date: 2026-04-23 Stores the list of email aliases a person owns in the external identity provider (primarily Google Workspace). Populated by the ``google.dept_sync`` handler: the per-person ``users().get`` call it already makes returns the ``aliases`` array for free, and persisting them lets downstream sync jobs (Zoom seat sync, future Slack/Feishu syncs) match external users whose primary address is one of the aliases rather than the canonical ``work_email``. Example: Zoom account ``reece.r@pingcap.com`` is an alias of HRIS person ``reece.reynolds@pingcap.com``. Before this column the Zoom seat sync silently skipped it (no identity_persons match). After, the shared email lookup helper considers both keys. Nullable JSON; NULL is treated as "no aliases known yet" (same as an empty list). Re-running google.dept_sync overwrites the list from Google — Google is the source of truth. """ import sqlalchemy as sa from alembic import op revision = "057" down_revision = "056" branch_labels = None depends_on = None def upgrade() -> None: op.add_column( "identity_persons", sa.Column("email_aliases", sa.JSON(), nullable=True), ) def downgrade() -> None: op.drop_column("identity_persons", "email_aliases")