mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-24 17:43:40 +00:00
Merge pull request #8735 from overleaf/msm-unset-allow-downgrade
[web] script to unset `history.allowDowngrade` in projects GitOrigin-RevId: c30dfa64bfdd492d659cce308628f9e118449d5c
This commit is contained in:
parent
e6b681838b
commit
88575dc58e
1 changed files with 46 additions and 0 deletions
46
services/web/scripts/history/unset_allow_downgrade.js
Normal file
46
services/web/scripts/history/unset_allow_downgrade.js
Normal file
|
@ -0,0 +1,46 @@
|
|||
const BATCH_SIZE = parseInt(process.env.BATCH_SIZE, 10) || 100
|
||||
// persist fallback in order to keep batchedUpdate in-sync
|
||||
process.env.BATCH_SIZE = BATCH_SIZE
|
||||
|
||||
const PROJECT_ID = process.env.PROJECT_ID
|
||||
|
||||
const {
|
||||
db,
|
||||
waitForDb,
|
||||
ObjectId,
|
||||
} = require('../../app/src/infrastructure/mongodb')
|
||||
const { batchedUpdate } = require('../helpers/batchedUpdate')
|
||||
|
||||
console.log({
|
||||
PROJECT_ID,
|
||||
BATCH_SIZE,
|
||||
VERBOSE_LOGGING: process.env.VERBOSE_LOGGING, // for batchedUpdate() logging
|
||||
})
|
||||
|
||||
async function main() {
|
||||
if (PROJECT_ID) {
|
||||
await waitForDb()
|
||||
const { modifiedCount } = await db.projects.updateOne(
|
||||
{ _id: ObjectId(PROJECT_ID), 'overleaf.history.allowDowngrade': true },
|
||||
{ $unset: { 'overleaf.history.allowDowngrade': 1 } }
|
||||
)
|
||||
console.log(`modifiedCount: ${modifiedCount}`)
|
||||
} else {
|
||||
await batchedUpdate(
|
||||
'projects',
|
||||
{ 'overleaf.history.allowDowngrade': true },
|
||||
{ $unset: { 'overleaf.history.allowDowngrade': 1 } }
|
||||
)
|
||||
}
|
||||
console.log('Final')
|
||||
}
|
||||
|
||||
main()
|
||||
.then(() => {
|
||||
console.error('Done.')
|
||||
process.exit(0)
|
||||
})
|
||||
.catch(error => {
|
||||
console.error({ error })
|
||||
process.exit(1)
|
||||
})
|
Loading…
Reference in a new issue