breaking: #10077, store nav items in objects
parent
3b0c42a591
commit
69c96078ea
@ -0,0 +1,28 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const db = require('../../database');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: 'Upgrade navigation items to hashes',
|
||||||
|
timestamp: Date.UTC(2021, 11, 13),
|
||||||
|
method: async function () {
|
||||||
|
const data = await db.getSortedSetRangeWithScores('navigation:enabled', 0, -1);
|
||||||
|
const order = [];
|
||||||
|
const bulkSet = [];
|
||||||
|
|
||||||
|
data.forEach((item) => {
|
||||||
|
const navItem = JSON.parse(item.value);
|
||||||
|
if (navItem.hasOwnProperty('properties') && navItem.properties) {
|
||||||
|
if (navItem.properties.hasOwnProperty('targetBlank')) {
|
||||||
|
navItem.targetBlank = navItem.properties.targetBlank;
|
||||||
|
}
|
||||||
|
delete navItem.properties;
|
||||||
|
}
|
||||||
|
bulkSet.push([`navigation:enabled:${item.score}`, navItem]);
|
||||||
|
order.push(item.score);
|
||||||
|
});
|
||||||
|
await db.setObjectBulk(bulkSet);
|
||||||
|
await db.delete('navigation:enabled');
|
||||||
|
await db.sortedSetAdd('navigation:enabled', order, order);
|
||||||
|
},
|
||||||
|
};
|
Loading…
Reference in New Issue