"""Add data-access resource catalog labels. Revision ID: 334 Revises: 333 Create Date: 2026-06-11 DAX-045 projects catalog feed labels into ``data_access_resources`` alongside the existing owner/source/version/etag fields. Labels are source metadata for request display and audit context; runtime owner authorization still reads only ``owner_person_id`` plus ``owner_resolution_status`` from the row. """ from __future__ import annotations import sqlalchemy as sa from alembic import op revision = "337" down_revision = "336" branch_labels = None depends_on = None TABLE = "data_access_resources" COLUMN = "labels" def _column_exists(bind, table: str, column: str) -> bool: return bool(bind.execute( sa.text( "SELECT 1 FROM information_schema.columns " "WHERE table_schema = DATABASE() " "AND table_name = :t AND column_name = :c LIMIT 1", ), {"t": table, "c": column}, ).scalar()) def upgrade() -> None: bind = op.get_bind() if not _column_exists(bind, TABLE, COLUMN): op.add_column(TABLE, sa.Column(COLUMN, sa.JSON(), nullable=True)) def downgrade() -> None: bind = op.get_bind() if _column_exists(bind, TABLE, COLUMN): op.drop_column(TABLE, COLUMN)