mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2025-07-23 23:00:08 +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
47 lines
1,018 B
JavaScript
47 lines
1,018 B
JavaScript
import { batchedUpdate } from '@overleaf/mongo-utils/batchedUpdate.js'
|
|
|
|
const tags = ['saas']
|
|
|
|
const migrate = async client => {
|
|
const { db } = client
|
|
await batchedUpdate(
|
|
db.ssoConfigs,
|
|
{ certificate: { $exists: true }, certificates: { $exists: false } },
|
|
[
|
|
{ $set: { certificates: ['$certificate'] } },
|
|
{
|
|
$unset: 'certificate',
|
|
},
|
|
]
|
|
)
|
|
await batchedUpdate(
|
|
db.ssoConfigs,
|
|
{ userFirstNameAttribute: null },
|
|
{ $unset: { userFirstNameAttribute: true } }
|
|
)
|
|
await batchedUpdate(
|
|
db.ssoConfigs,
|
|
{ userLastNameAttribute: null },
|
|
{ $unset: { userLastNameAttribute: true } }
|
|
)
|
|
}
|
|
|
|
const rollback = async client => {
|
|
const { db } = client
|
|
await batchedUpdate(
|
|
db.ssoConfigs,
|
|
{ certificate: { $exists: false }, certificates: { $exists: true } },
|
|
[
|
|
{ $set: { certificate: { $arrayElemAt: ['$certificates', 0] } } },
|
|
{
|
|
$unset: 'certificates',
|
|
},
|
|
]
|
|
)
|
|
}
|
|
|
|
export default {
|
|
tags,
|
|
migrate,
|
|
rollback,
|
|
}
|