Files
octopus/myproject/integrations/migrations/0004_revert_glm_model.py

30 lines
1.0 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Generated migration for reverting GLM model back to glm-4.7
from django.db import migrations
def revert_glm_model(apps, schema_editor):
"""Откатываем модель обратно на glm-4.7"""
GLMIntegration = apps.get_model('integrations', 'GLMIntegration')
# Обновляем все записи с glm-4-flash обратно на glm-4.7
GLMIntegration.objects.filter(model_name='glm-4-flash').update(model_name='glm-4.7')
def reverse_revert_glm_model(apps, schema_editor):
"""Применяем миграцию - возвращаем glm-4-flash"""
GLMIntegration = apps.get_model('integrations', 'GLMIntegration')
# Возвращаем glm-4-flash
GLMIntegration.objects.filter(model_name='glm-4.7').update(model_name='glm-4-flash')
class Migration(migrations.Migration):
dependencies = [
('integrations', '0003_update_glm_default_model'),
]
operations = [
migrations.RunPython(revert_glm_model, reverse_revert_glm_model),
]