Skip to content

Commit

Permalink
No longer upgrading from very old versions.
Browse files Browse the repository at this point in the history
  • Loading branch information
evert committed Aug 19, 2016
1 parent 8cf91a7 commit d078f09
Showing 1 changed file with 1 addition and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,73 +83,8 @@ function render() {

protected function upgrade($sVersionFrom, $sVersionTo) {

if ($sVersionFrom === "0.2.0") {

$sOldDbFilePath = PROJECT_PATH_SPECIFIC . "Db/.ht.db.sqlite";

if (PROJECT_SQLITE_FILE === $sOldDbFilePath) {
$sNewDbFilePath = PROJECT_PATH_SPECIFIC . "Db/db.sqlite";

# Move old db from Specific/Db/.ht.db.sqlite to Specific/Db/db.sqlite
if (!file_exists($sNewDbFilePath)) {
if (!is_writable(dirname($sNewDbFilePath))) {
$this->aErrors[] = "DB file path '" . dirname($sNewDbFilePath) . "' is not writable";
return false;
}

if (!@copy($sOldDbFilePath, $sNewDbFilePath)) {
$this->aErrors[] = "DB could not be copied from '" . $sOldDbFilePath . "' to '" . $sNewDbFilePath . "'.";
return false;
}

$this->aSuccess[] = "SQLite database has been renamed from '" . $sOldDbFilePath . "' to '" . $sNewDbFilePath . "'";
}
}
}

if (version_compare($sVersionFrom, '0.2.3', '<=')) {
# Upgrading DB

# etag VARCHAR(32),
# size INT(11) UNSIGNED NOT NULL,
# componenttype VARCHAR(8),
# firstoccurence INT(11) UNSIGNED,
# lastoccurence INT(11) UNSIGNED,

if (defined("PROJECT_DB_MYSQL") && PROJECT_DB_MYSQL === true) {
$aSql = [
"ALTER TABLE calendarobjects ADD COLUMN etag VARCHAR(32)",
"ALTER TABLE calendarobjects ADD COLUMN size INT(11) UNSIGNED NOT NULL",
"ALTER TABLE calendarobjects ADD COLUMN componenttype VARCHAR(8)",
"ALTER TABLE calendarobjects ADD COLUMN firstoccurence INT(11) UNSIGNED",
"ALTER TABLE calendarobjects ADD COLUMN lastoccurence INT(11) UNSIGNED",
"ALTER TABLE calendars ADD COLUMN transparent TINYINT(1) NOT NULL DEFAULT '0'",
];

$this->aSuccess[] = "MySQL database has been successfuly upgraded.";
} else {
$aSql = [
"ALTER TABLE calendarobjects ADD COLUMN etag text",
"ALTER TABLE calendarobjects ADD COLUMN size integer",
"ALTER TABLE calendarobjects ADD COLUMN componenttype text",
"ALTER TABLE calendarobjects ADD COLUMN firstoccurence integer",
"ALTER TABLE calendarobjects ADD COLUMN lastoccurence integer",
"ALTER TABLE calendars ADD COLUMN transparent bool",
"ALTER TABLE principals ADD COLUMN vcardurl text", # This one is added in SQLite but not MySQL, because it is already there since the beginning in MySQL
];

$this->aSuccess[] = "SQLite database has been successfuly upgraded.'";
}

try{
foreach ($aSql as $sAlterTableSql) {
$GLOBALS["DB"]->query($sAlterTableSql);
}
} catch (\Exception $e) {
$this->aSuccess = [];
$this->aErrors[] = "<p>Database cannot be upgraded.<br />Caught exception: " . $e->getMessage() . "</p>";
return false;
}
throw new \Exception('This version of Baikal does not support upgrading from version 0.2.3 and older. Please request help on Github if this is a problem.');
}

$pdo = $GLOBALS['DB']->getPDO();
Expand Down

0 comments on commit d078f09

Please sign in to comment.