"""Add NESSUS value to scans.scan_type enum

Revision ID: 014
Revises: 013
Create Date: 2026-05-18 10:00:00.000000

run_nessus_sync now writes one Scan row per host so Nessus syncs
appear in the Scan-Jobs history (previously only Wazuh did). Needs
a new enum value 'nessus' on scans.scan_type.

Idempotent — the ADD VALUE IF NOT EXISTS guard means re-running this
migration on a schema where the value already lives is a no-op.
"""
from alembic import op


revision = '014'
down_revision = '013'
branch_labels = None
depends_on = None


def upgrade() -> None:
    # Postgres enum ALTERs must run outside a transaction in older
    # versions. ADD VALUE IF NOT EXISTS is supported on 9.6+ and is
    # transaction-safe on 12+ which is our minimum target.
    op.execute("ALTER TYPE scantype ADD VALUE IF NOT EXISTS 'nessus'")


def downgrade() -> None:
    # Postgres has no DROP VALUE for enums. The downgrade is a no-op;
    # an existing 'nessus' value is harmless even after the model
    # stops emitting it.
    pass
