"""Give the built-in notification types real hex colors

Recognition/Recertification/Training stored keyword typecolors ('recognition'
etc.) that static color maps had to translate. Every other type already stores
a hex. This converts the three to hex so color is fully data-driven and the
static maps can go away. Their special behavior now rides on displaystyle /
splitperemployee / showemployeephoto, not the color keyword.

Revision ID: 7d06_typecolor_to_hex
Revises: 7d05_pc_access_protocols
Create Date: 2026-07-08

"""
from alembic import op
import sqlalchemy as sa


revision = '7d06_typecolor_to_hex'
down_revision = '7d05_pc_access_protocols'
branch_labels = None
depends_on = None


KEYWORD_HEX = {
    'recognition': '#ffc107',
    'recertification': '#0d6efd',
    'training': '#17a2b8',
}


def upgrade():
    conn = op.get_bind()
    for keyword, hexcolor in KEYWORD_HEX.items():
        conn.execute(
            sa.text("UPDATE notificationtypes SET typecolor = :hex WHERE typecolor = :kw"),
            {'hex': hexcolor, 'kw': keyword}
        )


def downgrade():
    conn = op.get_bind()
    for keyword, hexcolor in KEYWORD_HEX.items():
        conn.execute(
            sa.text("UPDATE notificationtypes SET typecolor = :kw WHERE typecolor = :hex"),
            {'kw': keyword, 'hex': hexcolor}
        )
