major
minor
major
minor
Optimizing the application schema in the database generally requires moving instances of certain types to a different (new) table that can accommodate more attributes and references in its columns, in order to reduce the generic storage of attribute values.
Such a move of instances, along with the simultaneous transfer of their attribute values to columns in the target table, can be performed using 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 further customize the events of moved objects during the move.
During the move, 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 prefixed:
#!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 are moved from the generic link table `hasWrapperAttValue ` 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 `.
Note that both rewriters only work in the context of ` model-index ` because they must resolve model references. In particular, the model index must index the moved `test.app.rewrite:MyType ` types so that the ` reference-has-type ` filter can resolve the type of source objects for the association links to be embedded.
Test
- test-app-rewrite from #26798