|
|
@ -27,15 +27,15 @@ require_once INSTALL_PATH . 'program/include/clisetup.php';
|
|
|
|
$opts = rcube_utils::get_opt(array(
|
|
|
|
$opts = rcube_utils::get_opt(array(
|
|
|
|
'v' => 'version',
|
|
|
|
'v' => 'version',
|
|
|
|
'd' => 'dir',
|
|
|
|
'd' => 'dir',
|
|
|
|
'l' => 'label',
|
|
|
|
'p' => 'package',
|
|
|
|
));
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
|
|
if (empty($opts['dir'])) {
|
|
|
|
if (empty($opts['dir'])) {
|
|
|
|
echo "ERROR: Database schema directory not specified (--dir).\n";
|
|
|
|
echo "ERROR: Database schema directory not specified (--dir).\n";
|
|
|
|
exit(1);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (empty($opts['label'])) {
|
|
|
|
if (empty($opts['package'])) {
|
|
|
|
echo "ERROR: Database schema label not specified (--label).\n";
|
|
|
|
echo "ERROR: Database schema package name not specified (--package).\n";
|
|
|
|
exit(1);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -60,7 +60,7 @@ if (in_array('system', (array)$DB->list_tables())) {
|
|
|
|
$DB->query("SELECT " . $DB->quote_identifier('value')
|
|
|
|
$DB->query("SELECT " . $DB->quote_identifier('value')
|
|
|
|
." FROM " . $DB->quote_identifier('system')
|
|
|
|
." FROM " . $DB->quote_identifier('system')
|
|
|
|
." WHERE " . $DB->quote_identifier('name') ." = ?",
|
|
|
|
." WHERE " . $DB->quote_identifier('name') ." = ?",
|
|
|
|
$opts['label'] . '-version');
|
|
|
|
$opts['package'] . '-version');
|
|
|
|
|
|
|
|
|
|
|
|
$row = $DB->fetch_array();
|
|
|
|
$row = $DB->fetch_array();
|
|
|
|
$version = $row[0];
|
|
|
|
$version = $row[0];
|
|
|
@ -126,7 +126,7 @@ sort($result, SORT_NUMERIC);
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($result as $v) {
|
|
|
|
foreach ($result as $v) {
|
|
|
|
echo "Updating database schema ($v)... ";
|
|
|
|
echo "Updating database schema ($v)... ";
|
|
|
|
$error = update_db_schema($opts['label'], $v, $dir . DIRECTORY_SEPARATOR . "$v.sql");
|
|
|
|
$error = update_db_schema($opts['package'], $v, $dir . DIRECTORY_SEPARATOR . "$v.sql");
|
|
|
|
|
|
|
|
|
|
|
|
if ($error) {
|
|
|
|
if ($error) {
|
|
|
|
echo "\nError in DDL upgrade $v: $error\n";
|
|
|
|
echo "\nError in DDL upgrade $v: $error\n";
|
|
|
@ -137,7 +137,7 @@ foreach ($result as $v) {
|
|
|
|
|
|
|
|
|
|
|
|
exit(0);
|
|
|
|
exit(0);
|
|
|
|
|
|
|
|
|
|
|
|
function update_db_schema($label, $version, $file)
|
|
|
|
function update_db_schema($package, $version, $file)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
global $DB;
|
|
|
|
global $DB;
|
|
|
|
|
|
|
|
|
|
|
@ -167,13 +167,13 @@ function update_db_schema($label, $version, $file)
|
|
|
|
$DB->query("UPDATE " . $DB->quote_identifier('system')
|
|
|
|
$DB->query("UPDATE " . $DB->quote_identifier('system')
|
|
|
|
." SET " . $DB->quote_identifier('value') . " = ?"
|
|
|
|
." SET " . $DB->quote_identifier('value') . " = ?"
|
|
|
|
." WHERE " . $DB->quote_identifier('name') . " = ?",
|
|
|
|
." WHERE " . $DB->quote_identifier('name') . " = ?",
|
|
|
|
$version, $label . '-version');
|
|
|
|
$version, $package . '-version');
|
|
|
|
|
|
|
|
|
|
|
|
if (!$DB->is_error() && !$DB->affected_rows()) {
|
|
|
|
if (!$DB->is_error() && !$DB->affected_rows()) {
|
|
|
|
$DB->query("INSERT INTO " . $DB->quote_identifier('system')
|
|
|
|
$DB->query("INSERT INTO " . $DB->quote_identifier('system')
|
|
|
|
." (" . $DB->quote_identifier('name') . ", " . $DB->quote_identifier('value') . ")"
|
|
|
|
." (" . $DB->quote_identifier('name') . ", " . $DB->quote_identifier('value') . ")"
|
|
|
|
." VALUES (?, ?)",
|
|
|
|
." VALUES (?, ?)",
|
|
|
|
$label . '-version', $version);
|
|
|
|
$package . '-version', $version);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return $DB->is_error();
|
|
|
|
return $DB->is_error();
|
|
|
|