Enhancement
Major
Detail
Major
Detail
Optimization of the application schema in the database usually requires moving instances of certain types to another (new) table, which can hold more attributes and references in columns, in order to reduce the generic storage of attribute values.
Such a move of instances with a simultaneous move of their attribute values into columns of the target table can be done via the following migration step:
#!xml <migration config:interface="com.top_logic.knowledge.service.migration.MigrationConfig" xmlns:config="http://www.top-logic.com/ns/config/6.0" > ... <migration> <steps> <step name="Move instances"> <model-index> <indexed-types> <type name="test.app.rewrite:MyType"/> </indexed-types> <move-to-table target-table="MyTable" > <types> <type name="test.app.rewrite:MyType"/> </types> </move-to-table> </model-index> </step> </steps> </migration> ... </migration>
An optional value-rewriter can thereby further customize the events of moved objects as they are moved.
When moved, primitive attributes are automatically moved to columns in the target table. If generic association links are to be embedded in reference columns, an association-inline rewriter can be prepended:
#!xml <association-inline types="hasWrapperAttValue" target-object="source" reference-value="dest" reference-name="myRefColumn" > <filters> <reference-has-type reference="source"> <types> <type name="test.app.rewrite:MyType"/> </types> </reference-has-type> <references-model-element reference="metaAttribute"> <model-elements> <model-element name="test.app.rewrite:MyType#myRef"/> </model-elements> </references-model-element> </filters> </association-inline>
Here, association links from the generic link table hasWrapperAttValue are moved to the reference column myRefColumn if the links originate from an object of type test.app.rewrite:MyType and are annotated with the model element test.app.rewrite:MyType#myRef.
It should be noted here that both rewriters only work in the context of model-index because they must resolve model references. In particular, model-index must index the moved types test.app.rewrite:MyType so that the reference-has-type filter can resolve the type of source objects of the association links to be embedded.
Test
- test-app-rewrite from #26798