<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def migrate(self, mapping, index, doc_type):
 """ Migrate a ES mapping :param mapping: new mapping :param index: index of old mapping :param doc_type: type of old mapping :return: The diff mapping """

        old_mapping = self.get_doctype(index, doc_type)
        #case missing
        if not old_mapping:
            self.connection.indices.put_mapping(doc_type=doc_type, mapping=mapping, indices=index)
            return mapping
            # we need to calculate the diff
        mapping_diff = old_mapping.get_diff(mapping)
        if not mapping_diff:
            return None
        from pprint import pprint

        pprint(mapping_diff.as_dict())
        mapping_diff.connection = old_mapping.connection
        mapping_diff.save()