aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/bin/migrateto21.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sabre/dav/bin/migrateto21.php')
-rw-r--r--vendor/sabre/dav/bin/migrateto21.php36
1 files changed, 13 insertions, 23 deletions
diff --git a/vendor/sabre/dav/bin/migrateto21.php b/vendor/sabre/dav/bin/migrateto21.php
index c81ee5cca..909643583 100644
--- a/vendor/sabre/dav/bin/migrateto21.php
+++ b/vendor/sabre/dav/bin/migrateto21.php
@@ -4,7 +4,6 @@
echo "SabreDAV migrate script for version 2.1\n";
if ($argc < 2) {
-
echo <<<HELLO
This script help you migrate from a pre-2.1 database to 2.1.
@@ -37,14 +36,13 @@ php {$argv[0]} sqlite:data/sabredav.db
HELLO;
exit();
-
}
// There's a bunch of places where the autoloader could be, so we'll try all of
// them.
$paths = [
- __DIR__ . '/../vendor/autoload.php',
- __DIR__ . '/../../../autoload.php',
+ __DIR__.'/../vendor/autoload.php',
+ __DIR__.'/../../../autoload.php',
];
foreach ($paths as $path) {
@@ -58,7 +56,7 @@ $dsn = $argv[1];
$user = isset($argv[2]) ? $argv[2] : null;
$pass = isset($argv[3]) ? $argv[3] : null;
-echo "Connecting to database: " . $dsn . "\n";
+echo 'Connecting to database: '.$dsn."\n";
$pdo = new PDO($dsn, $user, $pass);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
@@ -67,15 +65,14 @@ $pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
$driver = $pdo->getAttribute(PDO::ATTR_DRIVER_NAME);
switch ($driver) {
-
- case 'mysql' :
+ case 'mysql':
echo "Detected MySQL.\n";
break;
- case 'sqlite' :
+ case 'sqlite':
echo "Detected SQLite.\n";
break;
- default :
- echo "Error: unsupported driver: " . $driver . "\n";
+ default:
+ echo 'Error: unsupported driver: '.$driver."\n";
die(-1);
}
@@ -95,19 +92,17 @@ try {
echo "2.0 schema detected.\n";
$addUid = true;
}
-
} catch (Exception $e) {
echo "Could not find a calendarobjects table. Skipping this part of the\n";
echo "upgrade.\n";
}
if ($addUid) {
-
switch ($driver) {
- case 'mysql' :
+ case 'mysql':
$pdo->exec('ALTER TABLE calendarobjects ADD uid VARCHAR(200)');
break;
- case 'sqlite' :
+ case 'sqlite':
$pdo->exec('ALTER TABLE calendarobjects ADD uid TEXT');
break;
}
@@ -117,7 +112,6 @@ if ($addUid) {
$counter = 0;
while ($row = $result->fetch(\PDO::FETCH_ASSOC)) {
-
try {
$vobj = \Sabre\VObject\Reader::read($row['calendardata']);
} catch (\Exception $e) {
@@ -130,19 +124,16 @@ if ($addUid) {
echo "Warning! Item with id $item[id] does NOT have a UID property and this is required.\n";
continue;
}
- $uid = (string)$item->UID;
+ $uid = (string) $item->UID;
$stmt->execute([$uid, $row['id']]);
- $counter++;
-
+ ++$counter;
}
-
}
echo "Creating 'schedulingobjects'\n";
switch ($driver) {
-
- case 'mysql' :
+ case 'mysql':
$pdo->exec('CREATE TABLE IF NOT EXISTS schedulingobjects
(
id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
@@ -156,8 +147,7 @@ switch ($driver) {
');
break;
-
- case 'sqlite' :
+ case 'sqlite':
$pdo->exec('CREATE TABLE IF NOT EXISTS schedulingobjects (
id integer primary key asc,
principaluri text,