Merge pull request #492 from fruux/sqlite-synctoken-fix

Fix for #472
This commit is contained in:
Evert Pot 2016-03-12 18:18:37 -05:00
commit 182f0f555a
3 changed files with 58 additions and 2 deletions

View file

@ -1,6 +1,13 @@
ChangeLog ChangeLog
========= =========
0.4.0 (????-??-??)
------------------
* #472: If you were using Sqlite, Cal- CardDAV clients might have missed
updates from the server.
0.3.5 (2016-02-24) 0.3.5 (2016-02-24)
------------------ ------------------

View file

@ -24,5 +24,5 @@
# This copyright notice MUST APPEAR in all copies of the script! # This copyright notice MUST APPEAR in all copies of the script!
################################################################# #################################################################
define("BAIKAL_VERSION", "0.3.5"); define("BAIKAL_VERSION", "0.4.0");
define("BAIKAL_HOMEPAGE", "http://baikal-server.com"); define("BAIKAL_HOMEPAGE", "http://baikal-server.com");

View file

@ -151,9 +151,10 @@ HTML;
} }
} }
$pdo = $GLOBALS['DB']->getPDO();
if(version_compare($sVersionFrom, '0.3.0', '<')) { if(version_compare($sVersionFrom, '0.3.0', '<')) {
// Upgrading from sabre/dav 1.8 schema to 3.1 schema. // Upgrading from sabre/dav 1.8 schema to 3.1 schema.
$pdo = $GLOBALS['DB']->getPDO();
if(defined("PROJECT_DB_MYSQL") && PROJECT_DB_MYSQL === TRUE) { if(defined("PROJECT_DB_MYSQL") && PROJECT_DB_MYSQL === TRUE) {
// MySQL upgrade // MySQL upgrade
@ -376,6 +377,54 @@ HTML;
} }
$this->aSuccess[] = 'vcardurl was migrated to the propertystorage system'; $this->aSuccess[] = 'vcardurl was migrated to the propertystorage system';
}
if(version_compare($sVersionFrom, '0.4.0', '<')) {
// The sqlite schema had issues with both the calendar and
// addressbooks tables. The tables didn't have a DEFAULT '1' for
// the synctoken column. So we're adding it now.
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 (
id integer primary key asc NOT NULL,
principaluri text NOT NULL,
displayname text,
uri text NOT NULL,
synctoken integer DEFAULT 1 NOT NULL,
description text,
calendarorder integer,
calendarcolor text,
timezone text,
components text NOT NULL,
transparent bool
);');
$pdo->exec('INSERT INTO calendars SELECT * FROM calendars' . $tmpTable);
$pdo->exec('INSERT INTO addressbooks SELECT * FROM addressbooks' . $tmpTable);
$this->aSuccess[] = 'Updated calendars and addressbooks tables';
}
} }
$this->updateConfiguredVersion($sVersionTo); $this->updateConfiguredVersion($sVersionTo);