"""add_dashboard_token_hash_to_tenants

Revision ID: add_dashboard_token_hash
Revises: add_registration_tokens
Create Date: 2025-01-05 12:00:00.000000

This migration adds dashboard_token_hash column to tenants table
for authenticating dashboard-to-orchestrator communication.
"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = 'add_dashboard_token_hash'
down_revision: Union[str, None] = 'add_registration_tokens'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    op.add_column(
        'tenants',
        sa.Column(
            'dashboard_token_hash',
            sa.String(length=64),
            nullable=True,
            comment='SHA-256 hash of dashboard authentication token'
        )
    )


def downgrade() -> None:
    op.drop_column('tenants', 'dashboard_token_hash')
