aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/bin/migrateto30.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2019-11-10 12:49:51 +0000
committerMario <mario@mariovavti.com>2019-11-10 14:10:03 +0100
commit580c3f4ffe9608d2beb56d418c68b3b112420e76 (patch)
tree82335d01179ac361d3f547a4b8e8c598d302e9f3 /vendor/sabre/dav/bin/migrateto30.php
parentd22766f458a8539a40a57f3946459a9be1f21cd6 (diff)
downloadvolse-hubzilla-580c3f4ffe9608d2beb56d418c68b3b112420e76.tar.gz
volse-hubzilla-580c3f4ffe9608d2beb56d418c68b3b112420e76.tar.bz2
volse-hubzilla-580c3f4ffe9608d2beb56d418c68b3b112420e76.zip
another bulk of composer updates
(cherry picked from commit 6685381fd8db507493c3d7c1793f8c05c681bbce)
Diffstat (limited to 'vendor/sabre/dav/bin/migrateto30.php')
-rw-r--r--vendor/sabre/dav/bin/migrateto30.php44
1 files changed, 17 insertions, 27 deletions
diff --git a/vendor/sabre/dav/bin/migrateto30.php b/vendor/sabre/dav/bin/migrateto30.php
index 9ca77c13c..25e544c2a 100644
--- a/vendor/sabre/dav/bin/migrateto30.php
+++ b/vendor/sabre/dav/bin/migrateto30.php
@@ -4,7 +4,6 @@
echo "SabreDAV migrate script for version 3.0\n";
if ($argc < 2) {
-
echo <<<HELLO
This script help you migrate from a pre-3.0 database to 3.0 and later
@@ -36,14 +35,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) {
@@ -57,7 +55,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);
@@ -66,15 +64,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);
}
@@ -90,9 +87,8 @@ try {
echo "Renaming propertystorage -> propertystorage_old$random and creating new table.\n";
switch ($driver) {
-
- case 'mysql' :
- $pdo->exec('RENAME TABLE propertystorage TO propertystorage_old' . $random);
+ case 'mysql':
+ $pdo->exec('RENAME TABLE propertystorage TO propertystorage_old'.$random);
$pdo->exec('
CREATE TABLE propertystorage (
id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
@@ -102,10 +98,10 @@ try {
value MEDIUMBLOB
);
');
- $pdo->exec('CREATE UNIQUE INDEX path_property_' . $random . ' ON propertystorage (path(600), name(100));');
+ $pdo->exec('CREATE UNIQUE INDEX path_property_'.$random.' ON propertystorage (path(600), name(100));');
break;
- case 'sqlite' :
- $pdo->exec('ALTER TABLE propertystorage RENAME TO propertystorage_old' . $random);
+ case 'sqlite':
+ $pdo->exec('ALTER TABLE propertystorage RENAME TO propertystorage_old'.$random);
$pdo->exec('
CREATE TABLE propertystorage (
id integer primary key asc,
@@ -115,9 +111,8 @@ CREATE TABLE propertystorage (
value blob
);');
- $pdo->exec('CREATE UNIQUE INDEX path_property_' . $random . ' ON propertystorage (path, name);');
+ $pdo->exec('CREATE UNIQUE INDEX path_property_'.$random.' ON propertystorage (path, name);');
break;
-
}
} elseif (array_key_exists('valuetype', $row)) {
echo "valuetype field exists. Assuming that this part of the migration has\n";
@@ -126,7 +121,6 @@ CREATE TABLE propertystorage (
echo "2.1 schema detected. Going to perform upgrade.\n";
$addValueType = true;
}
-
} catch (Exception $e) {
echo "Could not find a propertystorage table. Skipping this part of the\n";
echo "upgrade.\n";
@@ -134,19 +128,17 @@ CREATE TABLE propertystorage (
}
if ($addValueType) {
-
switch ($driver) {
- case 'mysql' :
+ case 'mysql':
$pdo->exec('ALTER TABLE propertystorage ADD valuetype INT UNSIGNED');
break;
- case 'sqlite' :
+ case 'sqlite':
$pdo->exec('ALTER TABLE propertystorage ADD valuetype INT');
break;
}
$pdo->exec('UPDATE propertystorage SET valuetype = 1 WHERE valuetype IS NULL ');
-
}
echo "Migrating vcardurl\n";
@@ -155,16 +147,14 @@ $result = $pdo->query('SELECT id, uri, vcardurl FROM principals WHERE vcardurl I
$stmt1 = $pdo->prepare('INSERT INTO propertystorage (path, name, valuetype, value) VALUES (?, ?, 3, ?)');
while ($row = $result->fetch(\PDO::FETCH_ASSOC)) {
-
// Inserting the new record
$stmt1->execute([
- 'addressbooks/' . basename($row['uri']),
+ 'addressbooks/'.basename($row['uri']),
'{http://calendarserver.org/ns/}me-card',
- serialize(new Sabre\DAV\Xml\Property\Href($row['vcardurl']))
+ serialize(new Sabre\DAV\Xml\Property\Href($row['vcardurl'])),
]);
echo serialize(new Sabre\DAV\Xml\Property\Href($row['vcardurl']));
-
}
echo "Done.\n";