Search in sources :

Example 1 with MigrationBuilder

use of org.qi4j.migration.assembly.MigrationBuilder in project qi4j-sdk by Qi4j.

the class MigrationTest method assemble.

public void assemble(ModuleAssembly module) throws AssemblyException {
    new EntityTestAssembler().assemble(module);
    module.objects(MigrationEventLogger.class);
    module.importedServices(MigrationEventLogger.class).importedBy(NewObjectImporter.class);
    module.entities(TestEntity1_0.class, TestEntity1_1.class, TestEntity2_0.class, org.qi4j.migration.moved.TestEntity2_0.class);
    MigrationBuilder migration = new MigrationBuilder("1.0");
    migration.toVersion("1.1").renameEntity(TestEntity1_0.class.getName(), TestEntity1_1.class.getName()).atStartup(new CustomFixOperation("Fix for 1.1")).forEntities(TestEntity1_1.class.getName()).renameProperty("foo", "newFoo").renameManyAssociation("fooManyAssoc", "newFooManyAssoc").renameAssociation("fooAssoc", "newFooAssoc").end().toVersion("2.0").renameEntity(TestEntity1_1.class.getName(), TestEntity2_0.class.getName()).atStartup(new CustomFixOperation("Fix for 2.0, 1")).atStartup(new CustomFixOperation("Fix for 2.0, 2")).forEntities(TestEntity2_0.class.getName()).addProperty("bar", "Some value").removeProperty("newFoo", "Some value").custom(new CustomBarOperation()).end().toVersion("3.0").renamePackage("org.qi4j.migration", "org.qi4j.migration.moved").withEntities("TestEntity2_0").end();
    module.services(MigrationService.class).setMetaInfo(migration);
    module.entities(MigrationConfiguration.class);
    module.forMixin(MigrationConfiguration.class).declareDefaults().lastStartupVersion().set("1.0");
}
Also used : MigrationBuilder(org.qi4j.migration.assembly.MigrationBuilder) EntityTestAssembler(org.qi4j.test.EntityTestAssembler)

Aggregations

MigrationBuilder (org.qi4j.migration.assembly.MigrationBuilder)1 EntityTestAssembler (org.qi4j.test.EntityTestAssembler)1