mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-12 13:13:45 +01:00
[web] throw early in UserCreator.createNewUser with missing analyticsId (#34664)
* [web] throw early in UserCreator.createNewUser with missing analyticsId * [migrations] rerun back-fill of db.users.analyticsId GitOrigin-RevId: eabf16326192fca4dbea00ad643cee4315c426c6
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { db } from './lib/mongodb.mjs'
|
||||
import { batchedUpdate } from '@overleaf/mongo-utils/batchedUpdate.js'
|
||||
|
||||
const tags = ['saas', 'server-ce', 'server-pro', 'nonblocking']
|
||||
|
||||
const migrate = async () => {
|
||||
await batchedUpdate(db.users, { analyticsId: { $exists: false } }, [
|
||||
{ $set: { analyticsId: { $toString: '$_id' } } },
|
||||
])
|
||||
}
|
||||
|
||||
const rollback = async () => {
|
||||
await batchedUpdate(
|
||||
db.users,
|
||||
{ $expr: { $eq: [{ $strLenCP: '$analyticsId' }, 24] } },
|
||||
{ $unset: { analyticsId: 1 } }
|
||||
)
|
||||
}
|
||||
|
||||
export default {
|
||||
tags,
|
||||
migrate,
|
||||
rollback,
|
||||
}
|
||||
Reference in New Issue
Block a user