mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-14 20:14:18 +00:00
Merge pull request #11663 from overleaf/bg-add-migration-force-options
add migration force options GitOrigin-RevId: 51eb88e995a6e348e00208e9d01c9c1fa6c0c1ea
This commit is contained in:
parent
832a0facba
commit
89dd3b94b1
2 changed files with 20 additions and 4 deletions
services/web
|
@ -98,7 +98,7 @@ async function determineProjectHistoryType(project) {
|
|||
}
|
||||
}
|
||||
|
||||
async function upgradeProject(project) {
|
||||
async function upgradeProject(project, options) {
|
||||
const historyType = await determineProjectHistoryType(project)
|
||||
if (historyType === 'V2') {
|
||||
return { historyType, upgraded: true }
|
||||
|
@ -107,7 +107,7 @@ async function upgradeProject(project) {
|
|||
if (!upgradeFn) {
|
||||
return { error: 'unsupported history type' }
|
||||
}
|
||||
const result = await upgradeFn(project)
|
||||
const result = await upgradeFn(project, options)
|
||||
result.historyType = historyType
|
||||
return result
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
// raise mongo timeout to 1hr if otherwise unspecified
|
||||
process.env.MONGO_SOCKET_TIMEOUT =
|
||||
parseInt(process.env.MONGO_SOCKET_TIMEOUT, 10) || 3600000
|
||||
|
||||
const VERSION = '0.9.0-cli'
|
||||
const {
|
||||
countProjects,
|
||||
countDocHistory,
|
||||
|
@ -24,12 +26,16 @@ const DEFAULT_OUTPUT_FILE = `history-migration-${new Date()
|
|||
const argv = minimist(process.argv.slice(2), {
|
||||
boolean: [
|
||||
'verbose',
|
||||
'fix-invalid-characters',
|
||||
'convert-large-docs-to-file',
|
||||
'import-broken-history-as-zip',
|
||||
'force-upgrade-on-failure',
|
||||
'dry-run',
|
||||
'use-query-hint',
|
||||
'retry-failed',
|
||||
'archive-on-failure',
|
||||
],
|
||||
string: ['output'],
|
||||
string: ['output', 'user-id'],
|
||||
alias: {
|
||||
verbose: 'v',
|
||||
output: 'o',
|
||||
|
@ -153,13 +159,23 @@ async function migrateProjects(projectsToMigrate) {
|
|||
)
|
||||
}, 500)
|
||||
|
||||
const options = {
|
||||
migrationOptions: {
|
||||
archiveOnFailure: argv['import-broken-history-as-zip'],
|
||||
fixInvalidCharacters: argv['fix-invalid-characters'],
|
||||
forceNewHistoryOnFailure: argv['force-upgrade-on-failure'],
|
||||
},
|
||||
convertLargeDocsToFile: argv['convert-large-docs-to-file'],
|
||||
userId: argv['user-id'],
|
||||
reason: VERSION,
|
||||
}
|
||||
async function _migrateProject(project) {
|
||||
if (INTERRUPT) {
|
||||
return // don't start any new jobs if we're shutting down
|
||||
}
|
||||
const startTime = new Date()
|
||||
try {
|
||||
const result = await upgradeProject(project._id)
|
||||
const result = await upgradeProject(project._id, options)
|
||||
i++
|
||||
if (INTERRUPT && limit.activeCount > 1) {
|
||||
// an interrupt was requested while this job was running
|
||||
|
|
Loading…
Add table
Reference in a new issue