overleaf/services/web/migrations/20230124092607_clear_old_2fa_setup.mjs
Liangjun Song 26f3f3e2e2 Merge pull request #21097 from overleaf/ls-scripts-to-esm-1
Migrate scripts folder to esm 1/x

GitOrigin-RevId: 4a4bc9a161f144fdb40ce3f2a0a9313b36c6df81
2024-10-21 08:04:42 +00:00

37 lines
741 B
JavaScript

import BatchedUpdateScript from '../scripts/helpers/batchedUpdate.mjs'
const { batchedUpdate } = BatchedUpdateScript
const tags = ['saas']
const batchedUpdateOptions = {
VERBOSE_LOGGING: 'true',
BATCH_SIZE: '1',
}
const migrate = async () => {
await batchedUpdate(
'users',
{ 'twoFactorAuthentication.secret': { $exists: true } },
{ $unset: { twoFactorAuthentication: true } },
null,
null,
batchedUpdateOptions
)
}
const rollback = async () => {
await batchedUpdate(
'users',
{ 'twoFactorAuthentication.secretEncrypted': { $exists: true } },
{ $unset: { twoFactorAuthentication: true } },
null,
null,
batchedUpdateOptions
)
}
export default {
tags,
migrate,
rollback,
}