"""add workspace profile fields to user_tenants

Revision ID: c3d4e5f6a7b
Revises: b2c3d4e5f6a7
Create Date: 2026-05-08 00:00:00.000000

"""

from typing import Sequence, Union

import sqlalchemy as sa
from alembic import op

revision: str = "c3d4e5f6a7b"
down_revision: Union[str, None] = "ca7d3c4e8b2a"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    op.add_column(
        "user_tenants",
        sa.Column(
            "workspace_user_id",
            sa.String(length=255),
            nullable=True,
            comment="User ID (sub) proveniente de Workspace",
        ),
        schema="core",
    )
    op.add_column(
        "user_tenants",
        sa.Column(
            "workspace_avatar_url",
            sa.String(length=500),
            nullable=True,
            comment="Avatar URL sincronizado desde Workspace",
        ),
        schema="core",
    )
    op.add_column(
        "user_tenants",
        sa.Column(
            "workspace_profile_synced_at",
            sa.DateTime(timezone=True),
            nullable=True,
            comment="Última sincronización de perfil con Workspace",
        ),
        schema="core",
    )


def downgrade() -> None:
    op.drop_column("user_tenants", "workspace_profile_synced_at", schema="core")
    op.drop_column("user_tenants", "workspace_avatar_url", schema="core")
    op.drop_column("user_tenants", "workspace_user_id", schema="core")
