20260618090000_unset_reference_settings_migrated_flag.mjs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import { db } from './lib/mongodb.mjs'
  2. import { batchedUpdate } from '@overleaf/mongo-utils/batchedUpdate.js'
  3. // Cleanup following the removal of the reference manager settings migration
  4. // code (see #34507). The `migrated` flag was written alongside the
  5. // zotero/mendeley/papers settings during the local-storage -> mongo migration
  6. // and is no longer read or written, so we $unset it from existing user
  7. // documents.
  8. // Non-blocking: the field is already unused in code, so this cleanup does not
  9. // need to be applied before the deploy that ships it.
  10. const tags = ['saas', 'server-ce', 'server-pro', 'nonblocking']
  11. const MIGRATED_FIELDS = [
  12. 'ace.zotero.migrated',
  13. 'ace.mendeley.migrated',
  14. 'ace.papers.migrated',
  15. ]
  16. const migrate = async () => {
  17. await batchedUpdate(
  18. db.users,
  19. { $or: MIGRATED_FIELDS.map(field => ({ [field]: { $exists: true } })) },
  20. { $unset: Object.fromEntries(MIGRATED_FIELDS.map(field => [field, ''])) }
  21. )
  22. }
  23. // No rollback: the original per-user value of `migrated` is not recoverable and
  24. // the field is no longer used anywhere.
  25. const rollback = async () => {}
  26. export default {
  27. tags,
  28. migrate,
  29. rollback,
  30. }