def uncopy_preambles(apps, schema_editor):
    Preamble = apps.get_model('regcore', 'Preamble')
    Document = apps.get_model('regcore', 'Document')
    manager = mptt.managers.TreeManager()
    manager.model = Document
    mptt.register(Document)
    manager.contribute_to_class(Document, 'objects')
    for doc in Document.objects.filter(doc_type='preamble', root=True):
        nodes = doc.get_descendants(include_self=True)
        data = serialize(nodes[0], build_adjacency_map(nodes))
        pre = Preamble(document_number=doc.label_string, data=data)
        pre.save()
def uncopy_preambles(apps, schema_editor):
    Preamble = apps.get_model('regcore', 'Preamble')
    Document = apps.get_model('regcore', 'Document')
    manager = mptt.managers.TreeManager()
    manager.model = Document
    mptt.register(Document)
    manager.contribute_to_class(Document, 'objects')
    for doc in Document.objects.filter(doc_type='preamble', root=True):
        nodes = doc.get_descendants(include_self=True)
        data = serialize(nodes[0], build_adjacency_map(nodes))
        pre = Preamble(document_number=doc.label_string, data=data)
        pre.save()