@@ -0,0 +1,1199 @@
+# -*- coding: utf-8 -*-%0Aimport sys%0Aimport logging%0Afrom website.app import setup_django, init_app%0Afrom scripts import utils as script_utils%0Afrom django.db import transaction%0A%0Asetup_django()%0Afrom osf.models import AbstractNode%0A%0A%0Alogger = logging.getLogger(__name__)%0A%0A%0Adef do_migration():%0A    nodes = AbstractNode.objects.filter(template_node__type='osf.registration', type='osf.registration')%0A    # Avoid updating date_modified for migration%0A    date_modified_field = AbstractNode._meta.get_field('date_modified')%0A    date_modified_field.auto_now = False%0A    for node in nodes:%0A        logger.info('Casting Registration %7B%7D to a Node'.format(node._id))%0A        node._is_templated_clone = True%0A        node.recast('osf.node')%0A        node.save()%0A    date_modified_field.auto_now = True%0A    logger.info('Migrated %7B%7D nodes'.format(nodes.count()))%0A%0A%0Adef main(dry=True):%0A    init_app(routes=False)%0A    with transaction.atomic():%0A        do_migration()%0A        if dry:%0A            raise Exception('Abort Transaction - Dry Run')%0A%0A%0Aif __name__ == '__main__':%0A    dry = '--dry' in sys.argv%0A    if not dry:%0A        script_utils.add_file_logger(logger, __file__)%0A    # Finally run the migration%0A    main(dry=dry)%0A

Add script to clean up nodes that were templated from registrations