<commit_before>from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("models", "6014_bidirectional_resource_instance"),
    ]

    def forward_migrate(apps, schema_editor, with_create_permissions=True):
        nodes = apps.get_model("models", "Node")
        datatypes = apps.get_model("models", "DDataType")
        for datatype in datatypes.objects.filter(datatype__in=["resource-instance", "resource-instance-list"]):
            datatype.defaultconfig = {"graphs": []}
            datatype.save()

        for node in nodes.objects.filter(datatype__in=["resource-instance", "resource-instance-list"]):
            old_config = node.config
            new_config = {"graphs": []}
            for graphid in old_config["graphid"]:
                new_config["graphs"].append({"graphid": graphid, "ontologyProperty": "", "inverseOntologyProperty": ""})
            node.config = new_config
            node.save()
<commit_msg>Handles for cases in migration when no graphid is assigned to the related instance node, re #6020<commit_after>from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("models", "6014_bidirectional_resource_instance"),
    ]

    def forward_migrate(apps, schema_editor, with_create_permissions=True):
        nodes = apps.get_model("models", "Node")
        datatypes = apps.get_model("models", "DDataType")
        for datatype in datatypes.objects.filter(datatype__in=["resource-instance", "resource-instance-list"]):
            datatype.defaultconfig = {"graphs": []}
            datatype.save()

        for node in nodes.objects.filter(datatype__in=["resource-instance", "resource-instance-list"]):
            old_config = node.config
            new_config = {"graphs": []}
            if old_config["graphid"]:
                for graphid in old_config["graphid"]:
                    new_config["graphs"].append({"graphid": graphid, "ontologyProperty": "", "inverseOntologyProperty": ""})

            node.config = new_config
            node.save()

{'fraction_non_alphanumeric': 0.12874109263657957, 'fraction_numerical': 0.005700712589073635, 'mean_word_length': 3.0813953488372094, 'pattern_counts': {'":': 10, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4941234', 'n_tokens_mistral': 601, 'n_tokens_neox': 584, 'n_words': 114}