code: def move_identity(db, from_id, to_uuid):
      
      with db.connect() as session:
          fid = find_identity(session, from_id)
          tuid = find_unique_identity(session, to_uuid)
  
          if not fid:
              raise NotFoundError(entity=from_id)
          if not tuid:
              # Move identity to a new one
              if from_id == to_uuid:
                  tuid = add_unique_identity_db(session, to_uuid)
              else:
                  raise NotFoundError(entity=to_uuid)
  
          move_identity_db(session, fid, tuid)
docs: Move an identity to a unique identity.
  
      This function shifts the identity identified by 'from_id' to
      the unique identity 'to_uuid'.
  
      When 'to_uuid' is the unique identity that is currently related
      to 'from_id', the action does not have any effect.
  
      In the case of 'from_id' and 'to_uuid' have equal values and the
      unique identity does not exist, a new unique identity will be
      created and the identity will be moved to it.
  
      The function raises a 'NotFoundError exception when either 'from_id'
      or 'to_uuid' do not exist in the registry.
  
      :param from_id: identifier of the identity set to be moved
      :param to_uuid: identifier of the unique identity where 'from_id'
          will be moved
  
      :raises NotFoundError: raised when either 'from_uuid' or 'to_uuid'
          do not exist in the registry