Skip to content

LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows

1.9 KB
Raw Blame
# Generated by Django 4.2.30 on 2026-08-31 06:48

import logging

from django.db import migrations

logger = logging.getLogger(__name__)

ADAPTER_ID = "llmwhisperer|0a1647f0-f65f-410d-843b-3d979c78350e"

# Frozen copy of the adapter_processor_v2.deprecated_adapters entry. Runtime
# behaviour reads the registry, so wording drifting from it changes nothing.
DEPRECATION_METADATA = {
    "reason": (
        "LLMWhisperer V1 is retired. Please switch to the LLMWhisperer V2 "
        "text extractor."
    ),
    "deprecated_date": "2026-08-31",
    "replacement_adapter": "LLMWhisperer V2",
    "adapter_name": "LLMWhisperer",
    "adapter_type": "X2TEXT",
}


def mark_llmwhisperer_v1_deprecated(apps, schema_editor):
    """Mark every LLMWhisperer V1 instance unavailable, across all orgs.

    platform-service reads this column to reject execution, so a row missed
    here would fail deep in the SDK instead of with the deprecation message.
    """
    AdapterInstance = apps.get_model(  # NOSONAR
        "adapter_processor_v2", "AdapterInstance"
    )

    updated = AdapterInstance.objects.filter(adapter_id=ADAPTER_ID).update(
        is_available=False, deprecation_metadata=DEPRECATION_METADATA
    )
    logger.info("Marked %s LLMWhisperer V1 adapter instance(s) as deprecated.", updated)


def reverse_deprecation(apps, schema_editor):
    AdapterInstance = apps.get_model(  # NOSONAR
        "adapter_processor_v2", "AdapterInstance"
    )

    updated = AdapterInstance.objects.filter(adapter_id=ADAPTER_ID).update(
        is_available=True, deprecation_metadata=None
    )
    logger.info("Reversed deprecation for %s LLMWhisperer V1 instance(s).", updated)


class Migration(migrations.Migration):
    dependencies = [
        ("adapter_processor_v2", "0006_adapterinstance_adapter_org_modified_idx"),
    ]

    operations = [
        migrations.RunPython(mark_llmwhisperer_v1_deprecated, reverse_deprecation),
    ]