Skip to content

Commit

Permalink
Several issues fixed in the migration process.
Browse files Browse the repository at this point in the history
Fixes #566
  • Loading branch information
evert committed Nov 22, 2014
1 parent bf94308 commit 8e7b566
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions bin/migrateto21.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
echo "No data in table. Going to try to add the uid field anyway.\n";
$addUid = true;
} elseif (array_key_exists('uid', $row)) {
echo "uid field eixsts. Assuming that this part of the migration has\n";
echo "uid field exists. Assuming that this part of the migration has\n";
echo "Already been completed.\n";
} else {
echo "2.0 schema detected.\n";
Expand All @@ -113,7 +113,7 @@
}

$result = $pdo->query('SELECT id, calendardata FROM calendarobjects');
$stmt = $pdo->query('UPDATE calendarobjects SET uid = ? WHERE id = ?');
$stmt = $pdo->prepare('UPDATE calendarobjects SET uid = ? WHERE id = ?');
$counter = 0;

while($row = $result->fetch(\PDO::FETCH_ASSOC)) {
Expand All @@ -127,20 +127,13 @@
goto yoyo;
}
$uid = null;
foreach($vobj->select() as $item) {
if ($item instanceof \Sabre\VObject\Component) {
if ($item->name === 'VTIMEZONE') {
continue;
}
if (!isset($item->UID)) {
echo "Warning! Item with id $item[id] does NOT have a UID property and this is required.\n";
goto yoyo;
}
$uid = (string)$uid;

}
$item = $vobj->getBaseComponent();
if (!isset($item->UID)) {
echo "Warning! Item with id $item[id] does NOT have a UID property and this is required.\n";
goto yoyo;
}
$stmt->exec(array($uid, $row['id']));
$uid = (string)$uid;
$stmt->execute([$uid, $row['id']]);
$counter++;

}
Expand Down

0 comments on commit 8e7b566

Please sign in to comment.