@classmethod<EOL><INDENT>def migrate(cls, old, new, verbose=True, dry_run=False, rm_refs=True):<DEDENT>
if verbose:<EOL><INDENT>logging.basicConfig(format='<STR_LIT>',<EOL>level=logging.DEBUG)<EOL><DEDENT>deleted_fields = [field for field in old._fields if field not in new._fields]<EOL>added_fields = [field for field in new._fields if field not in old._fields]<EOL>logging.info('<STR_LIT>'.format(deleted_fields))<EOL>logging.info('<STR_LIT>'.format(added_fields))<EOL>if old._primary_name != new._primary_name:<EOL><INDENT>logging.info("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>.format(old_name=old._primary_name,<EOL>old_field=old._fields[old._primary_name],<EOL>new_name=new._primary_name,<EOL>new_field=new._fields[new._primary_name]))<EOL><DEDENT>for field in old._fields:<EOL><INDENT>if field not in cls._fields:<EOL><INDENT>if rm_refs:<EOL><INDENT>logging.info("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>".format(name=field,<EOL>field=old._fields[field]))<EOL>if not dry_run:<EOL><INDENT>rm_fwd_refs(old)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>logging.info("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>".format(name=field,<EOL>field=old._fields[field]))<EOL><DEDENT>continue<EOL><DEDENT>old_field_obj = old._fields[field]<EOL>new_field_obj = new._fields[field]<EOL>if old_field_obj != new_field_obj:<EOL><INDENT>if not old_field_obj._required and new_field_obj._required:<EOL><INDENT>logging.info("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>.format(name=field))<EOL><DEDENT>else:<EOL><INDENT>logging.info(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>".format(name=field,<EOL>old_field=old_field_obj,<EOL>new_field=new_field_obj)<EOL>)<EOL><DEDENT>continue<EOL><DEDENT>if not dry_run:<EOL><INDENT>field_object = cls._fields[field]<EOL>field_object.__set__(<EOL>new,<EOL>getattr(old, field),<EOL>safe=True<EOL>)<EOL><DEDENT><DEDENT>if not dry_run:<EOL><INDENT>new.__backrefs = old.__backrefs<EOL><DEDENT>if not dry_run:<EOL><INDENT>cls._migrate(old, new)<EOL><DEDENT>
Migrate record to new schema.

        :param old: Record from original schema
        :param new: Record from new schema
        :param verbose: Print detailed info
        :param dry_run: Dry run; make no changes if true
        :param rm_refs: Remove references on deleted fields