2024-11-08 03:34:14 -05:00
|
|
|
import { db } from '../app/src/infrastructure/mongodb.js'
|
|
|
|
import { batchedUpdate } from '@overleaf/mongo-utils/batchedUpdate.js'
|
2023-02-16 05:41:58 -05:00
|
|
|
|
2024-10-02 05:32:13 -04:00
|
|
|
const tags = ['saas']
|
2023-02-16 05:41:58 -05:00
|
|
|
|
|
|
|
const batchedUpdateOptions = {
|
|
|
|
VERBOSE_LOGGING: 'true',
|
|
|
|
BATCH_SIZE: '1',
|
|
|
|
}
|
|
|
|
|
2024-10-02 05:32:13 -04:00
|
|
|
const migrate = async () => {
|
2023-02-16 05:41:58 -05:00
|
|
|
await batchedUpdate(
|
2024-11-08 03:34:14 -05:00
|
|
|
db.users,
|
2023-02-16 05:41:58 -05:00
|
|
|
{ 'twoFactorAuthentication.secret': { $exists: true } },
|
|
|
|
{ $unset: { twoFactorAuthentication: true } },
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
batchedUpdateOptions
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2024-10-02 05:32:13 -04:00
|
|
|
const rollback = async () => {
|
2023-02-16 05:41:58 -05:00
|
|
|
await batchedUpdate(
|
2024-11-08 03:34:14 -05:00
|
|
|
db.users,
|
2023-02-16 05:41:58 -05:00
|
|
|
{ 'twoFactorAuthentication.secretEncrypted': { $exists: true } },
|
|
|
|
{ $unset: { twoFactorAuthentication: true } },
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
batchedUpdateOptions
|
|
|
|
)
|
|
|
|
}
|
2024-10-02 05:32:13 -04:00
|
|
|
|
|
|
|
export default {
|
|
|
|
tags,
|
|
|
|
migrate,
|
|
|
|
rollback,
|
|
|
|
}
|