"""Rename data_classification values to match Jira's real Data Sensitivity field. Jira's actual "Data Sensitivity" custom field (customfield_11814) has 6 options — Public, General Use, Internal Use Only, Trusted People, Customer Content, PII — not the 4-tier scheme Aegis invented independently. This migration replicates Jira's scheme so ticket sync stops guessing at a mapping. Applies to tests, campaigns, and evidences tables (all plain String(20) columns — no native enum type to alter). public_release -> public, confidential -> internal_use_only, restricted -> pii. general_use is unchanged. Revision ID: b060 Revises: b059 Create Date: 2026-07-09 """ from alembic import op revision = "b060" down_revision = "b059" branch_labels = None depends_on = None _TABLES = ("tests", "campaigns", "evidences") _RENAMES_UP = { "public_release": "public", "confidential": "internal_use_only", "restricted": "pii", } _RENAMES_DOWN = {v: k for k, v in _RENAMES_UP.items()} def upgrade() -> None: for table in _TABLES: for old, new in _RENAMES_UP.items(): op.execute(f"UPDATE {table} SET data_classification = '{new}' WHERE data_classification = '{old}'") op.alter_column(table, "data_classification", server_default="internal_use_only") def downgrade() -> None: for table in _TABLES: for new, old in _RENAMES_DOWN.items(): op.execute(f"UPDATE {table} SET data_classification = '{old}' WHERE data_classification = '{new}'") op.alter_column(table, "data_classification", server_default="confidential")