Data migrations (2)
So you don’t have to reset the database every time you change your schema.
Submitted by Zef Hemel on 30 March 2010 at 04:48
Issue Log
This feature is really needed.
Have you started working on this?
One of my colleagues’ research project is about automatically deriving data migrations. He ported his solution to mobl at one stage, but we never really put effort into getting it working. I’ll see if we can work on that. I see the necessity :)
Just an update: a simple data migration framework is in the works for 0.5. It’s pretty low-level at this point, but should work OK. Here’s some example code:
Migration.defineMigration(1, function(m : Migration) {
m.createEntity(“tasks::Task”);
m.addProperty(“tasks::Task”, “name”, “String”);
});Migration.defineMigration(2, function(m : Migration) {
m.addProperty(“tasks::Task”, “done”, “Bool”, true);
});Migration.defineMigration(3, function(m : Migration) {
m.createEntity(“tasks::Category”);
m.addProperty(“tasks::Task”, “category”, “tasks::Category”);
});Migration.defineMigration(4, function(m : Migration) {
m.createEntity(“tasks::Tag”);
m.addProperty(“tasks::Tag”, “name”, “mobl::String”);
m.addManyToMany(“tasks::Task”, “tags”, “tasks::Tag”, “tasks”);
});The migration is powered by persistence.js’ migrations plugin.
Needless to say, migrations will be applied automatically as the user loads the application (as needed).
Log in to post comments