"""add datasources to agents

Revision ID: 63647ca7796e
Revises: 7b9f8c1d2e3a
Create Date: 2026-03-31 12:00:00.000000
"""
import os
import sys
from typing import Sequence, Union

import sqlalchemy as sa

# Add alembic folder to path for utils import
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from utils import JsonEncoded, batch_alter_table

# revision identifiers, used by Alembic.
revision: str = "63647ca7796e"
down_revision: Union[str, None] = "7b9f8c1d2e3a"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    """Upgrade schema."""
    with batch_alter_table("agents") as batch_op:
        print("LOG_MESSAGE: adding the column datasources ...")
        batch_op.add_column(sa.Column("datasources", JsonEncoded(), nullable=True))


def downgrade() -> None:
    """Downgrade schema."""
    with batch_alter_table("agents") as batch_op:
        batch_op.drop_column("datasources")
