Ejemplo n.º 1
0
if ($options['lint-check']) {
    $matchType = $sourceType;
    $matchSchema = $sourceSchema;
    unset($sourceSchema);
    $sourceSchema = loadLintSchema($matchSchema, $cli);
} else {
    $matchSchema = loadDatabaseSchema($matchType, $matchDBHost, $matchDBUser, $matchDBPassword, $matchDBSocket, $matchDB, $cli);
    if (!$matchSchema) {
        $cli->error("Failed to load schema from match database");
        $script->shutdown(1);
    }
}
if ($options['reverse']) {
    $differences = eZDbSchemaChecker::diff($sourceSchema->schema(), $matchSchema->schema(), $sourceType, $matchType);
    if (!$options['check-only']) {
        $cli->output("-- Difference in SQL commands for " . $sourceSchema->schemaName());
        $sql = $sourceSchema->generateUpgradeFile($differences);
        $cli->output($sql);
    }
} else {
    $differences = eZDbSchemaChecker::diff($matchSchema->schema(), $sourceSchema->schema(), $matchType, $sourceType);
    if (!$options['check-only']) {
        $cli->output("-- Difference in SQL commands from " . $sourceSchema->schemaName() . " to " . $matchSchema->schemaName());
        $sql = $matchSchema->generateUpgradeFile($differences);
        $cli->output($sql);
    }
}
if (count($differences) > 0) {
    $script->setExitCode(1);
}
$script->shutdown();
Ejemplo n.º 2
0
    }
}
if ($Module->isCurrentAction('DBCheck')) {
    $db = eZDB::instance();
    $dbSchema = eZDbSchema::instance();
    // read original schema from dba file
    $originalSchema = eZDbSchema::read('share/db_schema.dba');
    // merge schemas from all active extensions that declare some db schema
    $extensionsdir = eZExtension::baseDirectory();
    foreach (eZExtension::activeExtensions() as $activeextension) {
        if (file_exists($extensionsdir . '/' . $activeextension . '/share/db_schema.dba')) {
            if ($extensionschema = eZDbSchema::read($extensionsdir . '/' . $activeextension . '/share/db_schema.dba')) {
                $originalSchema = eZDbSchema::merge($originalSchema, $extensionschema);
            }
        }
    }
    // transform schema to 'localized' version for current db
    // (we might as well convert $dbSchema to generic format and diff in generic format,
    // but eZDbSchemaChecker::diff does not know how to re-localize the generated sql
    $dbSchema->transformSchema($originalSchema, true);
    $differences = eZDbSchemaChecker::diff($dbSchema->schema(array('format' => 'local', 'force_autoincrement_rebuild' => true)), $originalSchema);
    $sqlDiff = $dbSchema->generateUpgradeFile($differences);
    if (strlen($sqlDiff) == 0) {
        $tpl->setVariable('upgrade_sql', 'ok');
    } else {
        $tpl->setVariable('upgrade_sql', $sqlDiff);
    }
}
$Result = array();
$Result['content'] = $tpl->fetch("design:setup/systemupgrade.tpl");
$Result['path'] = array(array('url' => false, 'text' => ezpI18n::tr('kernel/setup', 'System Upgrade')));