Commit 75e26aac4ea87809b03d09b2ac8707aa7db497a0

Authored by Neil Blakey-Milner
1 parent dd359f80

Add a CLI script to automatically perform the upgrades to the current

version of KnowledgeTree.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3381 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing 1 changed file with 44 additions and 0 deletions
bin/automated_upgrade.php 0 → 100644
  1 +<?php
  2 +
  3 +require_once('../config/dmsDefaults.php');
  4 +require_once(KT_DIR . '/lib/upgrades/upgrade.inc.php');
  5 +
  6 +if (!($default->dbAdminUser && $default->dbAdminPass)) {
  7 + print "You need to set up the administrator user for your database.\n";
  8 + print "Consult docs/UPGRADE.txt for more information\n";
  9 + exit(1);
  10 +}
  11 +
  12 +if (PEAR::isError($default->_admindb)) {
  13 + print "Your database administrator user credentials can not login.\n";
  14 + print "Consult docs/UPGRADE.txt for more information.\n";
  15 + exit(1);
  16 +}
  17 +
  18 +$query = sprintf('SELECT value FROM %s WHERE name = "knowledgeTreeVersion"', $default->system_settings_table);
  19 +$lastVersion = DBUtil::getOneResultKey($query, 'value');
  20 +$currentVersion = $default->systemVersion;
  21 +
  22 +$upgrades = describeUpgrade($lastVersion, $currentVersion);
  23 +
  24 +$i = 1;
  25 +foreach ($upgrades as $step) {
  26 + print "Upgrade step $i: " . $step->getDescription() . "\n";
  27 + $res = $step->performUpgrade();
  28 + print " RESULT: ";
  29 + if ($res === true) {
  30 + print "Success";
  31 + }
  32 + if (PEAR::isError($res)) {
  33 + if (is_a($res, strtolower("Upgrade_Already_Applied"))) {
  34 + print "Already applied";
  35 + } else {
  36 + print "ERROR\n";
  37 + print $res->toString();
  38 + }
  39 + }
  40 + print "\n";
  41 + $i++;
  42 +}
  43 +
  44 +?>
... ...