"""Add EUVD (ENISA) enrichment fields to vulnerabilities

Revision ID: 008
Revises: 007
Create Date: 2026-05-11 17:00:00.000000

Adds columns for ENISA EUVD catalogs:
- exploitedvulnerabilities (EU equivalent of CISA KEV)
- criticalvulnerabilities (ENISA-flagged critical CVEs)
"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


revision = '008'
down_revision = '007'
branch_labels = None
depends_on = None


def upgrade() -> None:
    op.add_column(
        'vulnerabilities',
        sa.Column('euvd_listed', sa.Boolean(), server_default='false', nullable=False)
    )
    op.add_column(
        'vulnerabilities',
        sa.Column('euvd_critical', sa.Boolean(), server_default='false', nullable=False)
    )
    op.add_column(
        'vulnerabilities',
        sa.Column('euvd_date_added', sa.DateTime(), nullable=True)
    )
    op.add_column(
        'vulnerabilities',
        sa.Column('euvd_id', sa.String(length=50), nullable=True)
    )
    op.create_index('ix_vulnerabilities_euvd_listed', 'vulnerabilities', ['euvd_listed'])


def downgrade() -> None:
    op.drop_index('ix_vulnerabilities_euvd_listed', table_name='vulnerabilities')
    op.drop_column('vulnerabilities', 'euvd_id')
    op.drop_column('vulnerabilities', 'euvd_date_added')
    op.drop_column('vulnerabilities', 'euvd_critical')
    op.drop_column('vulnerabilities', 'euvd_listed')
