mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-06-21 08:40:05 +00:00
device-config: Add migration for SUPERVISOR_DELTA_APPLY_TIMEOUT
The default value for the delta apply timeout was changed from `''` to `'0'` (note strings as these are database values) - but if the value existed in the database already, this would fail validation. We add a migration which will look explcitily for the failing value and switch it to the new default. Change-type: patch Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
committed by
Giovanni Garufi
parent
bdaf1bc41f
commit
f9626a3ee4
21
src/migrations/M00003.js
Normal file
21
src/migrations/M00003.js
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
exports.up = function(knex) {
|
||||||
|
return knex('deviceConfig')
|
||||||
|
.select('targetValues')
|
||||||
|
.then(([target]) => {
|
||||||
|
const targetValues = target.targetValues;
|
||||||
|
const jsonValues = JSON.parse(targetValues);
|
||||||
|
|
||||||
|
if (jsonValues['SUPERVISOR_DELTA_APPLY_TIMEOUT'] === '') {
|
||||||
|
jsonValues['SUPERVISOR_DELTA_APPLY_TIMEOUT'] = '0';
|
||||||
|
|
||||||
|
// Only update the database if we need to
|
||||||
|
return knex('deviceConfig').update({
|
||||||
|
targetValues: JSON.stringify(jsonValues),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function(knex, Promise) {
|
||||||
|
return Promise.reject(new Error('Not Implemented'));
|
||||||
|
};
|
Reference in New Issue
Block a user