code: private void updateUnique(EntityType entityType, Attribute attr, Attribute updatedAttr) {
      if (attr.isUnique() && !updatedAttr.isUnique()) {
        Attribute idAttr = entityType.getIdAttribute();
        if (idAttr != null && idAttr.getName().equals(attr.getName())) {
          throw new MolgenisDataException(
              format(
                  "ID attribute [%s] of entity [%s] must be unique",
                  attr.getName(), entityType.getId()));
        }
  
        dropUniqueKey(entityType, updatedAttr);
      } else if (!attr.isUnique() && updatedAttr.isUnique()) {
        createUniqueKey(entityType, updatedAttr);
      }
    }
docs: Updates unique constraint based on attribute unique changes.
  
  @param entityType entity meta data
  @param attr current attribute
  @param updatedAttr updated attribute