code: private void updateDataType(EntityType entityType, Attribute attr, Attribute updatedAttr) {
      Attribute idAttr = entityType.getIdAttribute();
      if (idAttr != null && idAttr.getName().equals(attr.getName())) {
        throw new MolgenisDataException(
            format(
                "Data type of entity [%s] attribute [%s] cannot be modified, because [%s] is an ID attribute.",
                entityType.getId(), attr.getName(), attr.getName()));
      }
  
      // do nothing on representation changes XREF --> CATEGORICAL
      if (isSingleReferenceType(attr) && isSingleReferenceType(updatedAttr)) {
        return;
      }
  
      // do nothing on representation changes MREF --> CATEGORICAL_MREF
      if (isMultipleReferenceType(attr) && isMultipleReferenceType(updatedAttr)) {
        return;
      }
  
      // remove foreign key on data type updates such as XREF --> STRING
      if (isSingleReferenceType(attr) && !isReferenceType(updatedAttr)) {
        dropForeignKey(entityType, attr);
      }
  
      if (isSingleReferenceType(attr) && isMultipleReferenceType(updatedAttr)) {
        updateManyToOneToManyToMany(entityType, attr, updatedAttr);
      } else if (isMultipleReferenceType(attr) && isSingleReferenceType(updatedAttr)) {
        updateManyToManyToManyToOne(entityType, attr, updatedAttr);
      } else {
        updateColumnDataType(entityType, updatedAttr);
      }
  
      // add foreign key on data type updates such as STRING --> XREF
      if (!isReferenceType(attr) && isSingleReferenceType(updatedAttr)) {
        createForeignKey(entityType, updatedAttr);
      }
    }
docs: Updates column data type and foreign key constraints based on data type update.
  
  @param entityType entity meta data
  @param attr current attribute
  @param updatedAttr updated attribute