Differential D16965 Diff 40827 src/infrastructure/storage/management/workflow/PhabricatorStorageManagementWorkflow.php
Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/storage/management/workflow/PhabricatorStorageManagementWorkflow.php
Show First 20 Lines • Show All 923 Lines • ▼ Show 20 Lines | final private function doUpgradeSchemata( | ||||
} | } | ||||
if ($init_only) { | if ($init_only) { | ||||
echo pht('Storage initialized.')."\n"; | echo pht('Storage initialized.')."\n"; | ||||
return 0; | return 0; | ||||
} | } | ||||
$applied_map = array(); | $applied_map = array(); | ||||
$state_map = array(); | |||||
foreach ($api_map as $ref_key => $api) { | foreach ($api_map as $ref_key => $api) { | ||||
$applied = $api->getAppliedPatches(); | $applied = $api->getAppliedPatches(); | ||||
// If we still have nothing applied, this is a dry run and we didn't | // If we still have nothing applied, this is a dry run and we didn't | ||||
// actually initialize storage. Here, just do nothing. | // actually initialize storage. Here, just do nothing. | ||||
if ($applied === null) { | if ($applied === null) { | ||||
if ($is_dryrun) { | if ($is_dryrun) { | ||||
continue; | continue; | ||||
} else { | } else { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'Database initialization on host "%s" applied no patches!', | 'Database initialization on host "%s" applied no patches!', | ||||
$ref_key)); | $ref_key)); | ||||
} | } | ||||
} | } | ||||
$applied = array_fuse($applied); | $applied = array_fuse($applied); | ||||
$state_map[$ref_key] = $applied; | |||||
if ($apply_only) { | if ($apply_only) { | ||||
if (isset($applied[$apply_only])) { | if (isset($applied[$apply_only])) { | ||||
if (!$this->force && !$is_dryrun) { | if (!$this->force && !$is_dryrun) { | ||||
echo phutil_console_wrap( | echo phutil_console_wrap( | ||||
pht( | pht( | ||||
'Patch "%s" has already been applied on host "%s". Are you '. | 'Patch "%s" has already been applied on host "%s". Are you '. | ||||
'sure you want to apply it again? This may put your storage '. | 'sure you want to apply it again? This may put your storage '. | ||||
▲ Show 20 Lines • Show All 135 Lines • ▼ Show 20 Lines | while (true) { | ||||
$t_end = microtime(true); | $t_end = microtime(true); | ||||
$duration = ($t_end - $t_begin); | $duration = ($t_end - $t_begin); | ||||
$duration_map[$key] = $duration; | $duration_map[$key] = $duration; | ||||
} | } | ||||
// If we're explicitly reapplying this patch, we don't need to | // If we're explicitly reapplying this patch, we don't need to | ||||
// mark it as applied. | // mark it as applied. | ||||
if (!isset($applied_map[$ref_key][$key])) { | if (!isset($state_map[$ref_key][$key])) { | ||||
$api->markPatchApplied($key, ($t_end - $t_begin)); | $api->markPatchApplied($key, ($t_end - $t_begin)); | ||||
$applied_map[$ref_key][$key] = true; | $applied_map[$ref_key][$key] = true; | ||||
} | } | ||||
} | } | ||||
// We applied this everywhere, so we're done with the patch. | // We applied this everywhere, so we're done with the patch. | ||||
unset($patches[$key]); | unset($patches[$key]); | ||||
$applied_something = true; | $applied_something = true; | ||||
▲ Show 20 Lines • Show All 52 Lines • Show Last 20 Lines |