# Generated by Django 5.2 on 2025-08-28 18:56

from django.db import migrations


def update_all_agents_to_manual(apps, schema_editor):
    """Update all existing agents from DEFAULT to MANUAL whitelist policy."""
    PersistentAgent = apps.get_model('api', 'PersistentAgent')
    
    # Update all agents with DEFAULT policy to MANUAL
    updated_count = PersistentAgent.objects.filter(
        whitelist_policy='default'
    ).update(
        whitelist_policy='manual'
    )
    
    if updated_count:
        print(f"Updated {updated_count} agents from DEFAULT to MANUAL whitelist policy")


def reverse_update(apps, schema_editor):
    """Reverse operation - not recommended but provided for completeness."""
    # We don't reverse this as it's a one-way simplification
    pass


class Migration(migrations.Migration):

    dependencies = [
        ('api', '0104_alter_persistentagent_whitelist_policy'),
    ]

    operations = [
        migrations.RunPython(
            update_all_agents_to_manual,
            reverse_update
        ),
    ]
