Source code for tcms.management.migrations.0013_remove_initial_qa_contact

# Generated by Django 6.0.6 on 2026-07-07 18:05

import json

from django.conf import settings
from django.db import migrations
from django.forms.models import model_to_dict


[docs] def forwards(apps, schema_editor): component_model = apps.get_model("management", "Component") for component in component_model.objects.all(): # backup current values file_name = f"kiwitcms-management-migration-0013-remove_initial_qa_contact-{component.pk}" file_name = settings.TEMP_DIR / file_name with file_name.open("w") as outfile: json.dump(model_to_dict(component), outfile)
[docs] def backwards(apps, schema_editor): component_model = apps.get_model("management", "Component") for component in component_model.objects.all(): # restore initial_qa_contact field value file_name = f"kiwitcms-management-migration-0013-remove_initial_qa_contact-{component.pk}" file_name = settings.TEMP_DIR / file_name with file_name.open("r") as infile: data = json.load(infile) component.initial_qa_contact = data["initial_qa_contact"] component.save()
[docs] class Migration(migrations.Migration): dependencies = [ ( "management", "0012_alter_classification_options_alter_component_options_and_more", ), ] operations = [ migrations.RunPython(forwards, backwards), migrations.RemoveField( model_name="component", name="initial_qa_contact", ), ]