diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c4fdeb..f532bd1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,23 @@ ChangeLog 0.5.0 (????-??-??) ------------------ -0.4.5 (????-??-??) + +0.4.6 (2016-08-19) +------------------ + +* Updated sabre/dav database definitions +* #559: Fix contacts in new addressbooks not syncing +* Now allows creation of calendars that contain VJOURNAL, VTODO and VEVENT. +* Upgrading from Baikal version 0.2.3 and older is no longer supported. +* Ships with sabre/dav 3.1.4 + + +0.4.5 (2016-05-28) ------------------ * #552: PHP 7.0.7 introduced a sublte BC break that caused Baikal to error. +* Upgraded sabre/dav, which fixes CardDAV performance problems. +* Ships with sabre/dav 3.1.4 0.4.4 (2016-03-30) diff --git a/Core/Frameworks/BaikalAdmin/Controller/Install/VersionUpgrade.php b/Core/Frameworks/BaikalAdmin/Controller/Install/VersionUpgrade.php index e3ae6d5..2783bda 100644 --- a/Core/Frameworks/BaikalAdmin/Controller/Install/VersionUpgrade.php +++ b/Core/Frameworks/BaikalAdmin/Controller/Install/VersionUpgrade.php @@ -83,73 +83,8 @@ HTML; 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[] = "

Database cannot be upgraded.
Caught exception: " . $e->getMessage() . "

"; - 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(); @@ -387,22 +322,9 @@ HTML; if (!defined("PROJECT_DB_MYSQL") || PROJECT_DB_MYSQL === false) { $pdo->exec('UPDATE calendars SET synctoken = 1 WHERE synctoken IS NULL'); - $pdo->exec('UPDATE addressbooks SET synctoken = 1 WHERE synctoken IS NULL'); $tmpTable = '_' . time(); $pdo->exec('ALTER TABLE calendars RENAME TO calendars' . $tmpTable); - $pdo->exec('ALTER TABLE addressbooks RENAME TO addressbooks' . $tmpTable); - - $pdo->exec(' -CREATE TABLE addressbooks ( - id integer primary key asc NOT NULL, - principaluri text NOT NULL, - displayname text, - uri text NOT NULL, - description text, - synctoken integer DEFAULT 1 NOT NULL -); - '); $pdo->exec(' CREATE TABLE calendars ( @@ -420,13 +342,42 @@ CREATE TABLE calendars ( );'); $pdo->exec('INSERT INTO calendars SELECT id, principaluri, displayname, uri, synctoken, description, calendarorder, calendarcolor, timezone, components, transparent FROM calendars' . $tmpTable); - $pdo->exec('INSERT INTO addressbooks SELECT id, principaluri, displayname, uri, description, synctoken FROM addressbooks' . $tmpTable); - $this->aSuccess[] = 'Updated calendars and addressbooks tables'; + $this->aSuccess[] = 'Updated calendars table'; } } + if (version_compare($sVersionFrom, '0.4.5', '<=')) { + + // Similar to upgrading from older than 0.4.5, there were still + // issues with a missing DEFAULT 1 for sthe synctoken field in the + // addressbook. + if (!defined("PROJECT_DB_MYSQL") || PROJECT_DB_MYSQL === false) { + + $pdo->exec('UPDATE addressbooks SET synctoken = 1 WHERE synctoken IS NULL'); + + $tmpTable = '_' . time(); + $pdo->exec('ALTER TABLE addressbooks RENAME TO addressbooks' . $tmpTable); + + $pdo->exec(' +CREATE TABLE addressbooks ( + id integer primary key asc NOT NULL, + principaluri text NOT NULL, + displayname text, + uri text NOT NULL, + description text, + synctoken integer DEFAULT 1 NOT NULL +); + '); + + $pdo->exec('INSERT INTO addressbooks SELECT id, principaluri, displayname, uri, description, synctoken FROM addressbooks' . $tmpTable); + $this->aSuccess[] = 'Updated addressbooks table'; + + } + + } + $this->updateConfiguredVersion($sVersionTo); return true; diff --git a/Core/Resources/Db/MySQL/db.sql b/Core/Resources/Db/MySQL/db.sql index 68e128a..6dc4e23 100644 --- a/Core/Resources/Db/MySQL/db.sql +++ b/Core/Resources/Db/MySQL/db.sql @@ -51,7 +51,7 @@ CREATE TABLE calendars ( calendarorder INT(11) UNSIGNED NOT NULL DEFAULT '0', calendarcolor VARBINARY(10), timezone TEXT, - components VARBINARY(20), + components VARBINARY(21), transparent TINYINT(1) NOT NULL DEFAULT '0', UNIQUE(principaluri, uri) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; diff --git a/Core/Resources/Db/SQLite/db.sql b/Core/Resources/Db/SQLite/db.sql index de9dfe5..e8b8d55 100644 --- a/Core/Resources/Db/SQLite/db.sql +++ b/Core/Resources/Db/SQLite/db.sql @@ -1,39 +1,39 @@ CREATE TABLE addressbooks ( - id integer primary key asc, - principaluri text, + id integer primary key asc NOT NULL, + principaluri text NOT NULL, displayname text, - uri text, + uri text NOT NULL, description text, - synctoken integer + synctoken integer DEFAULT 1 NOT NULL ); CREATE TABLE cards ( - id integer primary key asc, - addressbookid integer, + id integer primary key asc NOT NULL, + addressbookid integer NOT NULL, carddata blob, - uri text, + uri text NOT NULL, lastmodified integer, etag text, size integer ); CREATE TABLE addressbookchanges ( - id integer primary key asc, + id integer primary key asc NOT NULL, uri text, - synctoken integer, - addressbookid integer, - operation integer + synctoken integer NOT NULL, + addressbookid integer NOT NULL, + operation integer NOT NULL ); CREATE INDEX addressbookid_synctoken ON addressbookchanges (addressbookid, synctoken); CREATE TABLE calendarobjects ( - id integer primary key asc, - calendardata blob, - uri text, - calendarid integer, - lastmodified integer, - etag text, - size integer, + id integer primary key asc NOT NULL, + calendardata blob NOT NULL, + uri text NOT NULL, + calendarid integer NOT NULL, + lastmodified integer NOT NULL, + etag text NOT NULL, + size integer NOT NULL, componenttype text, firstoccurence integer, lastoccurence integer, @@ -41,34 +41,34 @@ CREATE TABLE calendarobjects ( ); CREATE TABLE calendars ( - id integer primary key asc, - principaluri text, + id integer primary key asc NOT NULL, + principaluri text NOT NULL, displayname text, - uri text, - synctoken integer, + uri text NOT NULL, + synctoken integer DEFAULT 1 NOT NULL, description text, calendarorder integer, calendarcolor text, timezone text, - components text, + components text NOT NULL, transparent bool ); CREATE TABLE calendarchanges ( - id integer primary key asc, + id integer primary key asc NOT NULL, uri text, - synctoken integer, - calendarid integer, - operation integer + synctoken integer NOT NULL, + calendarid integer NOT NULL, + operation integer NOT NULL ); CREATE INDEX calendarid_synctoken ON calendarchanges (calendarid, synctoken); CREATE TABLE calendarsubscriptions ( - id integer primary key asc, - uri text, - principaluri text, - source text, + id integer primary key asc NOT NULL, + uri text NOT NULL, + principaluri text NOT NULL, + source text NOT NULL, displayname text, refreshrate text, calendarorder integer, @@ -80,19 +80,19 @@ CREATE TABLE calendarsubscriptions ( ); CREATE TABLE schedulingobjects ( - id integer primary key asc, - principaluri text, + id integer primary key asc NOT NULL, + principaluri text NOT NULL, calendardata blob, - uri text, + uri text NOT NULL, lastmodified integer, - etag text, - size integer + etag text NOT NULL, + size integer NOT NULL ); CREATE INDEX principaluri_uri ON calendarsubscriptions (principaluri, uri); BEGIN TRANSACTION; CREATE TABLE locks ( - id integer primary key asc, + id integer primary key asc NOT NULL, owner text, timeout integer, created integer, @@ -103,35 +103,33 @@ CREATE TABLE locks ( ); COMMIT; CREATE TABLE principals ( - id INTEGER PRIMARY KEY ASC, - uri TEXT, + id INTEGER PRIMARY KEY ASC NOT NULL, + uri TEXT NOT NULL, email TEXT, displayname TEXT, UNIQUE(uri) ); CREATE TABLE groupmembers ( - id INTEGER PRIMARY KEY ASC, - principal_id INTEGER, - member_id INTEGER, + id INTEGER PRIMARY KEY ASC NOT NULL, + principal_id INTEGER NOT NULL, + member_id INTEGER NOT NULL, UNIQUE(principal_id, member_id) ); - CREATE TABLE propertystorage ( - id integer primary key asc, - path text, - name text, - valuetype integer, + id integer primary key asc NOT NULL, + path text NOT NULL, + name text NOT NULL, + valuetype integer NOT NULL, value string ); CREATE UNIQUE INDEX path_property ON propertystorage (path, name); CREATE TABLE users ( - id integer primary key asc, - username TEXT, - digesta1 TEXT, + id integer primary key asc NOT NULL, + username TEXT NOT NULL, + digesta1 TEXT NOT NULL, UNIQUE(username) ); -