Changing Attribute Type Mappings

It may happen that the mapping an attribute type has in Fiona 7 needs to be changed subsequently, i.e. after attributes of this type have already been created and used. This is the case if, for example, the child_order attribute was given the linklist type which causes links to be created in the CMS for the target objects, making it difficult to delete them later on due to consistency checking.

The type of an attribute can be changed later on, however, a couple of aspects need to be observed when doing this.

The data is migrated automatically, but only after sorting the attribute content once again and releasing the object concerned. Only then, the existing links, for example, are deleted. In practice, this has the temporary effect that the attribute data of some objects is stored in the new format, while the data of other objects is stored in the old format. It is important to be aware of this behavior, especially if the data is also accessed differently, e.g. via TCL.

1. Remove the attribute from the CMS

First, the attribute concerned needs to be removed from all object classes, and then deleted. This task can be automated using the Ruby console. In the example below, the child_order attribute is removed:

['ObjClass1', 'ObjClass2', 'ObjClass3'].each do |obj_class|
  Fiona7::Tools::AttributeRemover.new(obj_class, :child_order).remove
end

The AttributeRemover class removes the attribute from the given object class and deletes it afterwards unless it is in use elsewhere.

2. Adapt the configuration

After removing the attribute, the new type mapping can be specified. See also: Specifying Attribute Type Mappings

Fiona7.custom_attribute_types = {
  child_order: :text
}

3. Migrating the CMS objects

The objects containing attributes with a changed type mapping are converted to the new format as they are edited and released. This happens behind the scenes, so editors won't notice anything.

The procedure described here should not be confused with the removal of attribute definitions from Ruby classes. Removing an attribute definition does not delete the attribute itself; it only becomes invisible to editors.