"""Add data-driven shopfloor display behavior to notification types

Replaces the hardcoded recognition/training/recertification logic with per-type
columns: split one card per employee, show employee photo, and the display
style (standard rows / carousel / grid / banner). Seeds the built-in special
types by their typecolor keyword.

Revision ID: 7d04_notificationtype_display
Revises: 7d03_notificationtype_expiry
Create Date: 2026-07-08

"""
from alembic import op
import sqlalchemy as sa


revision = '7d04_notificationtype_display'
down_revision = '7d03_notificationtype_expiry'
branch_labels = None
depends_on = None


def upgrade():
    op.add_column('notificationtypes', sa.Column('splitperemployee', sa.Boolean(), nullable=True, server_default='0'))
    op.add_column('notificationtypes', sa.Column('showemployeephoto', sa.Boolean(), nullable=True, server_default='0'))
    op.add_column('notificationtypes', sa.Column('displaystyle', sa.String(length=20), nullable=True, server_default='standard'))

    conn = op.get_bind()
    conn.execute(sa.text(
        "UPDATE notificationtypes SET splitperemployee=1, showemployeephoto=1, displaystyle='carousel' "
        "WHERE typecolor='recognition'"))
    conn.execute(sa.text(
        "UPDATE notificationtypes SET splitperemployee=1, showemployeephoto=1, displaystyle='grid' "
        "WHERE typecolor='recertification'"))
    conn.execute(sa.text(
        "UPDATE notificationtypes SET splitperemployee=1, showemployeephoto=1, displaystyle='carousel' "
        "WHERE typecolor='training'"))


def downgrade():
    op.drop_column('notificationtypes', 'displaystyle')
    op.drop_column('notificationtypes', 'showemployeephoto')
    op.drop_column('notificationtypes', 'splitperemployee')
