30 lines
1.0 KiB
Python
30 lines
1.0 KiB
Python
# Generated migration for updating GLM default model
|
||
|
||
from django.db import migrations
|
||
|
||
|
||
def update_glm_default_model(apps, schema_editor):
|
||
"""Обновляем модель по умолчанию для существующих записей GLM"""
|
||
GLMIntegration = apps.get_model('integrations', 'GLMIntegration')
|
||
|
||
# Обновляем все записи с glm-4.7 на glm-4-flash
|
||
GLMIntegration.objects.filter(model_name='glm-4.7').update(model_name='glm-4-flash')
|
||
|
||
|
||
def reverse_update_glm_default_model(apps, schema_editor):
|
||
"""Откат миграции - возвращаем glm-4.7"""
|
||
GLMIntegration = apps.get_model('integrations', 'GLMIntegration')
|
||
|
||
# Возвращаем glm-4.7
|
||
GLMIntegration.objects.filter(model_name='glm-4-flash').update(model_name='glm-4.7')
|
||
|
||
|
||
class Migration(migrations.Migration):
|
||
dependencies = [
|
||
('integrations', '0002_glmintegration_and_more'),
|
||
]
|
||
|
||
operations = [
|
||
migrations.RunPython(update_glm_default_model, reverse_update_glm_default_model),
|
||
]
|