Parcourir la source

Merge pull request #26580 from overleaf/jpa-fix-null-array

[web] add migration for fixing collaborator arrays on projects

GitOrigin-RevId: 73178b56501025bf23f463e8f9822fc33ecaaea0
Jakob Ackermann il y a 1 an
Parent
commit
1543f0a53e

+ 29 - 0
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,
+}