I have just committed a first draft of the migration API and service. I made it a part of the JDBM entitystore, but it should be moved out to its own extension ASAP, as it really has nothing to do with JDBM (I just put it there for convenience).

If you are interested, please take a look at the API used to declare the rules, and see if they seem to make sense. Look at MigrationTest for example of how to use it.

I have designed the API to allow for both upgrades and downgrades. In some cases you may want to export data from a new installation and import into an older one, for example. The API allows such changes to be handled. There's also a custom migrator where you can perform any change you want. As you get access to the JSON-object for the Entity you can pretty much do whatever you want with it.

Here's the sample code from MigrationTest:
MigrationRules migration = new MigrationRules();
migration.fromVersion("1.0").

   toVersion("1.1").
       renameEntity(TestEntity1_0.class.getName(),
                    TestEntity1_1.class.getName()).
       forEntities(TestEntity1_1.class.getName()).
           renameProperty( "foo", "newFoo").

   toVersion( "2.0" ).
       renameEntity(TestEntity1_1.class.getName(),
                    TestEntity2_0.class.getName()).
       forEntities( TestEntity2_0.class.getName() ).
           addProperty("bar", "Some value").
           removeProperty( "newFoo", "Some value" );

module.addServices( MigrationService.class ).setMetaInfo( migration );
---

Comments/suggestions?

I guess this is related to the qi4j ApplicationAssembly.version() that has been added? The thing is I cannot see that method in the ApplicaitonAssembly interface, only in the ApplicationAssemblyImpl. This means that our build fails. I have temporarily added an instanceof check and a cast to ApplicationAssemblyImpl to invoke the version method.

So what are the rules? Every time we add/change something we increment the minor version and extend the migration rules? It seems very good, but I cannot find the MigrationTest...

Regards,
Mads



_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev

Reply via email to