mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
cff54eae78
Fix history chunk replacement transaction GitOrigin-RevId: fc0fa8f4a55ae5f402ba87db5e4ac2856fe6627b
44 lines
964 B
JavaScript
44 lines
964 B
JavaScript
const { ObjectId } = require('mongodb')
|
|
const {
|
|
db,
|
|
waitForDb,
|
|
READ_PREFERENCE_SECONDARY,
|
|
} = require('../../app/src/infrastructure/mongodb')
|
|
const {
|
|
upgradeProject,
|
|
} = require('../../modules/history-migration/app/src/HistoryUpgradeHelper')
|
|
|
|
async function processProject(project) {
|
|
const result = await upgradeProject(project)
|
|
console.log(result)
|
|
}
|
|
|
|
async function main() {
|
|
await waitForDb()
|
|
const args = process.argv.slice(2)
|
|
const projectId = args[0]
|
|
const query = { _id: ObjectId(projectId) }
|
|
const projection = {
|
|
_id: 1,
|
|
overleaf: 1,
|
|
}
|
|
const options = {
|
|
projection,
|
|
readPreference: READ_PREFERENCE_SECONDARY,
|
|
}
|
|
const project = await db.projects.findOne(query, options)
|
|
if (project) {
|
|
await processProject(project)
|
|
} else {
|
|
console.error(`project ${projectId} not found`)
|
|
}
|
|
}
|
|
|
|
main()
|
|
.then(() => {
|
|
process.exit(0)
|
|
})
|
|
.catch(error => {
|
|
console.error({ error })
|
|
process.exit(1)
|
|
})
|