def recreate_parent_dependencies(apps, schema_editor):
    """Create empty dependency relation if parent has been deleted."""
    Data = apps.get_model('flow', 'Data')
    DataDependency = apps.get_model('flow', 'DataDependency')

    def process_dependency(data, parent):
        if not Data.objects.filter(pk=parent).exists():
            DataDependency.objects.create(
                child=data, parent=None, kind='io'
            )

    for data in Data.objects.all():
        for field_schema, fields in iterate_fields(data.input, data.process.input_schema):
            name = field_schema['name']
            value = fields[name]

            if field_schema.get('type', '').startswith('data:'):
                process_dependency(data, value)

            elif field_schema.get('type', '').startswith('list:data:'):
                for parent in value:
                    process_dependency(data, parent)
def recreate_parent_dependencies ( apps , schema_editor ) : Data = apps . get_model ( 'flow' , 'Data' ) DataDependency = apps . get_model ( 'flow' , 'DataDependency' ) def process_dependency ( data , parent ) : if not Data . objects . filter ( pk = parent ) . exists ( ) : DataDependency . objects . create ( child = data , parent = None , kind = 'io' ) for data in Data . objects . all ( ) : for field_schema , fields in iterate_fields ( data . input , data . process . input_schema ) : name = field_schema [ 'name' ] value = fields [ name ] if field_schema . get ( 'type' , '' ) . startswith ( 'data:' ) : process_dependency ( data , value ) elif field_schema . get ( 'type' , '' ) . startswith ( 'list:data:' ) : for parent in value : process_dependency ( data , parent )
Create empty dependency relation if parent has been deleted.