mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-30 05:42:15 -05:00
6f55a99ae1
Add script for converting individual projects to FPH and history upgrade helper GitOrigin-RevId: 4cf075e08045869fe87724fb28949fe91b780e93
38 lines
904 B
JavaScript
38 lines
904 B
JavaScript
const { ReadPreference, ObjectId } = require('mongodb')
|
|
const { db, waitForDb } = require('../../app/src/infrastructure/mongodb')
|
|
const { upgradeProject } = require('./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: ReadPreference.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)
|
|
})
|