mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-02-07 20:00:25 +00:00
96ecef8052
Change-type: patch Signed-off-by: Cameron Diver <cameron@balena.io>
21 lines
784 B
JavaScript
21 lines
784 B
JavaScript
const _ = require('lodash');
|
|
|
|
// We take legacy deviceConfig targets and store them without the RESIN_ prefix
|
|
// (we also strip the BALENA_ prefix for completeness, even though no supervisors
|
|
// using this prefix made it to production)
|
|
exports.up = function (knex, Promise) {
|
|
return knex('deviceConfig').select('targetValues')
|
|
.then((devConfigs) => {
|
|
const devConfig = devConfigs[0];
|
|
const targetValues = JSON.parse(devConfig.targetValues);
|
|
const filteredTargetValues = _.mapKeys(targetValues, (_v, k) => {
|
|
return k.replace(/^(?:RESIN|BALENA)_(.*)/, '$1');
|
|
});
|
|
return knex('deviceConfig').update({ targetValues: JSON.stringify(filteredTargetValues) });
|
|
});
|
|
};
|
|
|
|
exports.down = function (knex, Promise) {
|
|
return Promise.reject(new Error('Not Implemented'));
|
|
};
|