コード例 #1
0
foreach ($argv as $i => $arg) {
    if ($i) {
        switch ($arg) {
            case '--dry-run':
                $dryRun = true;
                break;
            default:
                print "Unknown flag {$arg} -- ignored\n";
                exit;
        }
    }
}
if ($dryRun) {
    print "---- DRY RUN ONLY ----\n";
}
$schemaVersion = db_tableExists('Variable') ? Variable::peek('Schema.version', '00000') : '00000';
print "Current schema version is <{$schemaVersion}>\n";
$patchFiles = getPatches(PATCH_DIR, $schemaVersion);
$numPatches = 0;
foreach ($patchFiles as $fileName) {
    runPatch(PATCH_DIR . $fileName, $dryRun);
    $numPatches++;
    $schemaVersion = stripExtension($fileName);
    if (!$dryRun) {
        // Update after each patch, in case one of the patches terminates with error.
        Variable::poke('Schema.version', $schemaVersion);
    }
}
print "{$numPatches} patches applied.\n";
print "New schema version is <{$schemaVersion}>\n";
/*****************************************************************/