| 544 | |
| 545 | An imperative migration is a Java class that is derived from `de.deepamehta.core.service.Migration` and that overrides the `run()` method. The `run()` method is called by DeepaMehta to run the migration. |
| 546 | |
| 547 | Within the migration you have access to the //DeepaMehta Core Service// through the `dms` object. By the means of the DeepaMehta Core Service you can perform arbitrary database operations. Typically this involves importing further objects from the `de.deepamehta.core` API. |
| 548 | |
| 549 | As an example see a migration that comes with the //DeepaMehta 4 Topicmaps// plugin: |
| 550 | |
| 551 | {{{ |
| 552 | #!java |
| 553 | package de.deepamehta.plugins.topicmaps.migrations; |
| 554 | |
| 555 | import de.deepamehta.core.TopicType; |
| 556 | import de.deepamehta.core.model.AssociationDefinitionModel; |
| 557 | import de.deepamehta.core.service.Migration; |
| 558 | |
| 559 | public class Migration3 extends Migration { |
| 560 | |
| 561 | @Override |
| 562 | public void run() { |
| 563 | TopicType type = dms.getTopicType("dm4.topicmaps.topicmap", null); |
| 564 | type.addAssocDef(new AssociationDefinitionModel("dm4.core.composition_def", |
| 565 | "dm4.topicmaps.topicmap", "dm4.topicmaps.state", "dm4.core.one", "dm4.core.one")); |
| 566 | } |
| 567 | } |
| 568 | }}} |
| 569 | |
| 570 | Here an association definition is added to the //Topicmap// type subsequently. |