# Generated migration for updating GLM model from glm-4-flash to glm-4

from django.db import migrations


def update_glm_model_to_glm4(apps, schema_editor):
    """Обновляем модель с glm-4-flash на glm-4"""
    GLMIntegration = apps.get_model('integrations', 'GLMIntegration')
    
    # Обновляем все записи с glm-4-flash на glm-4
    GLMIntegration.objects.filter(model_name='glm-4-flash').update(model_name='glm-4')


def reverse_update_glm_model_to_glm4(apps, schema_editor):
    """Откат миграции - возвращаем glm-4-flash"""
    GLMIntegration = apps.get_model('integrations', 'GLMIntegration')
    
    # Возвращаем glm-4-flash
    GLMIntegration.objects.filter(model_name='glm-4').update(model_name='glm-4-flash')


class Migration(migrations.Migration):
    dependencies = [
        ('integrations', '0005_update_glm_model_to_glm4'),
    ]

    operations = [
        migrations.RunPython(update_glm_model_to_glm4, reverse_update_glm_model_to_glm4),
    ]
