mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2025-07-25 02:00:07 +02:00

* [web] fix typo in ESM migration of a db migration * [web] migrate old migration to ESM * [web] use batchedUpdate for bulk updates in old migrations GitOrigin-RevId: a984f785c577c2ac4125c947b8a3efffa57e1eb7
46 lines
810 B
JavaScript
46 lines
810 B
JavaScript
import { batchedUpdate } from '@overleaf/mongo-utils/batchedUpdate.js'
|
|
|
|
const tags = ['saas']
|
|
|
|
const migrate = async client => {
|
|
const { db } = client
|
|
await batchedUpdate(
|
|
db.subscriptions,
|
|
{
|
|
'teamInvites.0': {
|
|
$exists: true,
|
|
},
|
|
},
|
|
[
|
|
{
|
|
$set: {
|
|
teamInvites: {
|
|
$map: {
|
|
input: '$teamInvites',
|
|
in: {
|
|
$mergeObjects: [
|
|
'$$this',
|
|
{
|
|
email: {
|
|
$toLower: '$$this.email',
|
|
},
|
|
},
|
|
],
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
]
|
|
)
|
|
}
|
|
|
|
const rollback = async () => {
|
|
// There is no way back.
|
|
}
|
|
|
|
export default {
|
|
tags,
|
|
migrate,
|
|
rollback,
|
|
}
|