diff --git a/src/upgrades/3.1.0/reset_user_bootswatch_skin.js b/src/upgrades/3.1.0/reset_user_bootswatch_skin.js new file mode 100644 index 0000000000..21d5569b39 --- /dev/null +++ b/src/upgrades/3.1.0/reset_user_bootswatch_skin.js @@ -0,0 +1,24 @@ +'use strict'; + + +const db = require('../../database'); + +module.exports = { + name: 'Reset old bootswatch skin for all users', + timestamp: Date.UTC(2023, 4, 1), + method: async function () { + const batch = require('../../batch'); + const css = require('../../meta/css'); + + batch.processSortedSet('users:joindate', async (uids) => { + let settings = await db.getObjects(uids.map(uid => `user:${uid}:settings`)); + settings = settings.filter( + s => s && s.bootswatchSkin && !css.supportedSkins.includes(s.bootswatchSkin) + ); + + await db.setObjectBulk(settings.map(s => ([`user:${s.uid}`, { bootswatchSkin: '' }]))); + }, { + batch: 500, + }); + }, +};