diff --git a/services/web/migrations/20250620152657_ensure_collaborator_arrays.mjs b/services/web/migrations/20250620152657_ensure_collaborator_arrays.mjs new file mode 100644 index 0000000000..3caa210d41 --- /dev/null +++ b/services/web/migrations/20250620152657_ensure_collaborator_arrays.mjs @@ -0,0 +1,29 @@ +import { batchedUpdate } from '@overleaf/mongo-utils/batchedUpdate.js' +import { db } from '../app/src/infrastructure/mongodb.js' + +const tags = ['server-ce', 'server-pro', 'saas'] + +const migrate = async () => { + const fields = [ + 'collaberator_refs', + 'pendingEditor_refs', + 'pendingReviewer_refs', + 'readOnly_refs', + 'reviewer_refs', + ] + for (const field of fields) { + await batchedUpdate( + db.projects, + { [field]: { $type: 'null' } }, + { $set: { [field]: [] } } + ) + } +} + +const rollback = async () => {} + +export default { + tags, + migrate, + rollback, +}