"""Reference Data Registry (Missão 5, Fase 1): additive columns on datasets for licence terms, vigência, file provenance, parse errors and admin approval tracking. Existing rows/kinds are untouched - new nullable columns, no data migration, no behavior change for the 9 pre-existing dataset kinds (their own service.py ingestion methods still auto-activate exactly as before). Revision ID: 0034_reference_data_registry Revises: 0032_contribuinte_ipi Note: migration 0033_cfop_ippt_write_mode exists ONLY on feature/cfop-ippt-write, never merged to master - this migration chains from 0032 (master's real head), not from 0033. """ from alembic import op import sqlalchemy as sa revision = "0034_reference_data_registry" down_revision = "0032_contribuinte_ipi" branch_labels = None depends_on = None def upgrade(): op.add_column("datasets", sa.Column("licence_terms", sa.Text(), nullable=True)) op.add_column("datasets", sa.Column("valid_from", sa.String(32), nullable=True)) op.add_column("datasets", sa.Column("valid_to", sa.String(32), nullable=True)) op.add_column("datasets", sa.Column("file_size_bytes", sa.Integer(), nullable=True)) op.add_column("datasets", sa.Column("raw_file_path", sa.Text(), nullable=True)) op.add_column("datasets", sa.Column("parse_errors", sa.JSON(), nullable=False, server_default="{}")) op.add_column("datasets", sa.Column("submitted_by", sa.String(128), nullable=True)) op.add_column("datasets", sa.Column("approved_by", sa.String(128), nullable=True)) op.add_column("datasets", sa.Column("approved_at", sa.DateTime(timezone=True), nullable=True)) def downgrade(): for name in ("approved_at", "approved_by", "submitted_by", "parse_errors", "raw_file_path", "file_size_bytes", "valid_to", "valid_from", "licence_terms"): op.drop_column("datasets", name)