Files
overleaf-cep/services/web/scripts/writefull/migrate_to_promotion_set.mjs
Jimmy Domagala-Tang 97c4c550d7 Migrate user.writefull.enabled -> user.writefull.promotionSet (#31475)
* feat: migrate from aiErrorAssist naming for disabling AI features to aiFeatures.enabled to avoid confusion

feat: keep aiErrorAssistant as setting on user object until migration is run

* feat: migrate writefull.enabled unset to instead use promotionSet false

* Update tools/migrations/20260213102825_swap_writefull_enabled_for_initialized.mjs

Co-authored-by: Mathias Jakobsen <mathias.jakobsen@overleaf.com>

* feat: addind backfill of ai features as a migration as well to help with dev environment setup

---------

Co-authored-by: Mathias Jakobsen <mathias.jakobsen@overleaf.com>
GitOrigin-RevId: fd3f0fc07c91678cd7fd1e0d5237221694b3027b
2026-02-18 09:05:38 +00:00

31 lines
776 B
JavaScript

import { db } from '../../app/src/infrastructure/mongodb.mjs'
import { batchedUpdate } from '@overleaf/mongo-utils/batchedUpdate.js'
import { scriptRunner } from '../lib/ScriptRunner.mjs'
async function main(trackProgress) {
// if writefull.enabled is unset or null then the account has no promotion attached yet
await batchedUpdate(db.users, {}, [
{
$set: {
'writefull.initialized': {
$or: [
{ $eq: ['$writefull.enabled', true] },
{ $eq: ['$writefull.enabled', false] },
],
},
},
},
])
console.log('completed migration to writefull.initialized')
}
export default main
try {
await scriptRunner(main)
process.exit(0)
} catch (error) {
console.error({ error })
process.exit(1)
}