2023-04-18 07:15:34 -04:00
|
|
|
const { ObjectId } = require('mongodb')
|
|
|
|
const {
|
|
|
|
db,
|
|
|
|
waitForDb,
|
|
|
|
READ_PREFERENCE_SECONDARY,
|
|
|
|
} = require('../../app/src/infrastructure/mongodb')
|
2023-01-23 05:35:26 -05:00
|
|
|
const {
|
|
|
|
upgradeProject,
|
|
|
|
} = require('../../modules/history-migration/app/src/HistoryUpgradeHelper')
|
2022-05-30 06:18:11 -04:00
|
|
|
|
|
|
|
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,
|
2023-04-18 07:15:34 -04:00
|
|
|
readPreference: READ_PREFERENCE_SECONDARY,
|
2022-05-30 06:18:11 -04:00
|
|
|
}
|
|
|
|
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)
|
|
|
|
})
|