code: private void updateRefEntity(EntityType entityType, Attribute attr, Attribute updatedAttr) {
      if (isSingleReferenceType(attr) && isSingleReferenceType(updatedAttr)) {
        dropForeignKey(entityType, attr);
  
        if (attr.getRefEntity().getIdAttribute().getDataType()
            != updatedAttr.getRefEntity().getIdAttribute().getDataType()) {
          updateColumnDataType(entityType, updatedAttr);
        }
  
        createForeignKey(entityType, updatedAttr);
      } else if (isMultipleReferenceType(attr) && isMultipleReferenceType(updatedAttr)) {
        throw new MolgenisDataException(
            format(
                "Updating entity [%s] attribute [%s] referenced entity from [%s] to [%s] not allowed for type [%s]",
                entityType.getId(),
                attr.getName(),
                attr.getRefEntity().getId(),
                updatedAttr.getRefEntity().getId(),
                updatedAttr.getDataType().toString()));
      }
    }
docs: Updates foreign keys based on referenced entity changes.
  
  @param entityType entity meta data
  @param attr current attribute
  @param updatedAttr updated attribute