Updating Config Bucket Schema
Each config bucket record has a 'schema_version' slot that, if set, indicates the schema version of the record. If the schema for the bucket needs to be changed, the following steps should be taken:
- Make the slot changes for the config bucket - only new slots should be added since the system should support running with out of date records until they can be properly updated
- Modify the code that reads the config records to properly handle out of date records
- Set the schema_version attribute for the Bucket to indicate that the schema has changed (ie, set to 1 or increment it by 1 or already set, or increment the minor decimal part of the version if that makes more sense)
- This will result in all of the config records being considered 'out_of_date' with the Bucket schema version (when the record is displayed on a Details page, a message indicating that the record is out of date will be shown)
- Create a Bucket schema fix script (see below) - this is used to convert out of date records to the new schema version
- Run the fix script against the ds.base and other "folder" bundles so the platform updates can be pushed along with the platform support for the new schema version
Since the platform cannot update all Bundles at upgrade time, the Bucket schema fix scripts are used to update a single bundle at a time as needed. If the platform upgraded all records in a system at upgrade time then one or more updates would be created to be pushed, which does not make sense until you are the developer of the bundle and want to upgrade the bundle to the new platform version. Instead, the platform identifies when a config record is out of date and prompt the user to run the fix scripts against the config records in the bundle so that the updates and push can be properly handled by the bundle developer. All other bundle users will then just have to pull the bundle to be up to date.
Bucket schema fix script
A bucket schema fix script is a script that is executed to update all config records within a bundle to the correct schema version. A Bucket schema fix script contains:
- Bucket to be upgraded
- Schema version to update to
- Fix script used to update the records within a bundle
The Fix script looks like this:
var BucketSchemaFix = Class.create({
runFix: function(bundleId) {
// Add fix script here!
}
});
module.exports = BucketSchemaFix;
The runFix function is passed the name of the bundle to upgrade. Add the necessary logic to update the config records to this Schema version to the runFix function.