Table migration (#2327)

* Added table migration code

* First working version

* Fixed issues with objects missing from composition
This commit is contained in:
Andrew Henry
2019-03-25 22:19:33 -07:00
committed by Deep Tailor
parent c7ffcbf7e0
commit e3f4da19f9
2 changed files with 226 additions and 180 deletions

View File

@@ -20,19 +20,21 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
import migrations from './Migrations.js'
import Migrations from './Migrations.js'
export default function () {
function needsMigration(domainObject) {
return migrations.some(m => m.check(domainObject));
}
function migrateObject(domainObject) {
return migrations.filter(m => m.check(domainObject))[0]
.migrate(domainObject);
}
return function (openmct) {
let migrations = Migrations(openmct);
function needsMigration(domainObject) {
return migrations.some(m => m.check(domainObject));
}
function migrateObject(domainObject) {
return migrations.filter(m => m.check(domainObject))[0]
.migrate(domainObject);
}
let wrappedFunction = openmct.objects.get;
openmct.objects.get = function migrate(identifier) {
return wrappedFunction.apply(openmct.objects, [identifier])
@@ -46,6 +48,6 @@ export default function () {
}
return object;
});
}
}
};
}
}