migrate therinaldos.com data
Build & Deploy to DigitalOcean Space / build (push) Failing after 2m38s

This commit is contained in:
2024-05-05 15:50:45 -04:00
commit ef1ff240d4
23182 changed files with 3801898 additions and 0 deletions
@@ -0,0 +1,92 @@
<?php
/**
* @copyright 2017 Georg Ehrke <oc.list@georgehrke.com>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Georg Ehrke <oc.list@georgehrke.com>
* @author Joas Schilling <coding@schilljs.com>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\Migration;
use OCP\BackgroundJob\IJobList;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;
class BuildCalendarSearchIndex implements IRepairStep {
/** @var IDBConnection */
private $db;
/** @var IJobList */
private $jobList;
/** @var IConfig */
private $config;
/**
* @param IDBConnection $db
* @param IJobList $jobList
* @param IConfig $config
*/
public function __construct(IDBConnection $db,
IJobList $jobList,
IConfig $config) {
$this->db = $db;
$this->jobList = $jobList;
$this->config = $config;
}
/**
* @return string
*/
public function getName() {
return 'Registering building of calendar search index as background job';
}
/**
* @param IOutput $output
*/
public function run(IOutput $output) {
// only run once
if ($this->config->getAppValue('dav', 'buildCalendarSearchIndex') === 'yes') {
$output->info('Repair step already executed');
return;
}
$query = $this->db->getQueryBuilder();
$query->select($query->createFunction('MAX(' . $query->getColumnName('id') . ')'))
->from('calendarobjects');
$result = $query->execute();
$maxId = (int) $result->fetchOne();
$result->closeCursor();
$output->info('Add background job');
$this->jobList->add(BuildCalendarSearchIndexBackgroundJob::class, [
'offset' => 0,
'stopAt' => $maxId
]);
// if all were done, no need to redo the repair during next upgrade
$this->config->setAppValue('dav', 'buildCalendarSearchIndex', 'yes');
}
}
@@ -0,0 +1,122 @@
<?php
/**
* @copyright 2017 Georg Ehrke <oc.list@georgehrke.com>
*
* @author Georg Ehrke <oc.list@georgehrke.com>
* @author Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\Migration;
use OC\BackgroundJob\QueuedJob;
use OCA\DAV\CalDAV\CalDavBackend;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\IJobList;
use OCP\IDBConnection;
use OCP\ILogger;
class BuildCalendarSearchIndexBackgroundJob extends QueuedJob {
/** @var IDBConnection */
private $db;
/** @var CalDavBackend */
private $calDavBackend;
/** @var ILogger */
private $logger;
/** @var IJobList */
private $jobList;
/** @var ITimeFactory */
private $timeFactory;
/**
* @param IDBConnection $db
* @param CalDavBackend $calDavBackend
* @param ILogger $logger
* @param IJobList $jobList
* @param ITimeFactory $timeFactory
*/
public function __construct(IDBConnection $db,
CalDavBackend $calDavBackend,
ILogger $logger,
IJobList $jobList,
ITimeFactory $timeFactory) {
$this->db = $db;
$this->calDavBackend = $calDavBackend;
$this->logger = $logger;
$this->jobList = $jobList;
$this->timeFactory = $timeFactory;
}
public function run($arguments) {
$offset = (int) $arguments['offset'];
$stopAt = (int) $arguments['stopAt'];
$this->logger->info('Building calendar index (' . $offset .'/' . $stopAt . ')');
$startTime = $this->timeFactory->getTime();
while (($this->timeFactory->getTime() - $startTime) < 15) {
$offset = $this->buildIndex($offset, $stopAt);
if ($offset >= $stopAt) {
break;
}
}
if ($offset >= $stopAt) {
$this->logger->info('Building calendar index done');
} else {
$this->jobList->add(self::class, [
'offset' => $offset,
'stopAt' => $stopAt
]);
$this->logger->info('New building calendar index job scheduled with offset ' . $offset);
}
}
/**
* @param int $offset
* @param int $stopAt
* @return int
*/
private function buildIndex(int $offset, int $stopAt): int {
$query = $this->db->getQueryBuilder();
$query->select(['id', 'calendarid', 'uri', 'calendardata'])
->from('calendarobjects')
->where($query->expr()->lte('id', $query->createNamedParameter($stopAt)))
->andWhere($query->expr()->gt('id', $query->createNamedParameter($offset)))
->orderBy('id', 'ASC')
->setMaxResults(500);
$result = $query->execute();
while ($row = $result->fetch(\PDO::FETCH_ASSOC)) {
$offset = $row['id'];
$calendarData = $row['calendardata'];
if (is_resource($calendarData)) {
$calendarData = stream_get_contents($calendarData);
}
$this->calDavBackend->updateProperties($row['calendarid'], $row['uri'], $calendarData);
}
return $offset;
}
}
@@ -0,0 +1,92 @@
<?php
/**
* @copyright 2017 Georg Ehrke <oc.list@georgehrke.com>
*
* @author call-me-matt <nextcloud@matthiasheinisch.de>
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\Migration;
use OCP\BackgroundJob\IJobList;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;
class BuildSocialSearchIndex implements IRepairStep {
/** @var IDBConnection */
private $db;
/** @var IJobList */
private $jobList;
/** @var IConfig */
private $config;
/**
* @param IDBConnection $db
* @param IJobList $jobList
* @param IConfig $config
*/
public function __construct(IDBConnection $db,
IJobList $jobList,
IConfig $config) {
$this->db = $db;
$this->jobList = $jobList;
$this->config = $config;
}
/**
* @return string
*/
public function getName() {
return 'Register building of social profile search index as background job';
}
/**
* @param IOutput $output
*/
public function run(IOutput $output) {
// only run once
if ($this->config->getAppValue('dav', 'builtSocialSearchIndex') === 'yes') {
$output->info('Repair step already executed');
return;
}
$query = $this->db->getQueryBuilder();
$query->select($query->func()->max('cardid'))
->from('cards_properties')
->where($query->expr()->eq('name', $query->createNamedParameter('X-SOCIALPROFILE')));
$maxId = (int)$query->execute()->fetchOne();
if ($maxId === 0) {
return;
}
$output->info('Add background job');
$this->jobList->add(BuildSocialSearchIndexBackgroundJob::class, [
'offset' => 0,
'stopAt' => $maxId
]);
// no need to redo the repair during next upgrade
$this->config->setAppValue('dav', 'builtSocialSearchIndex', 'yes');
}
}
@@ -0,0 +1,121 @@
<?php
/**
* @copyright 2020 Matthias Heinisch <nextcloud@matthiasheinisch.de>
*
* @author call-me-matt <nextcloud@matthiasheinisch.de>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\Migration;
use OC\BackgroundJob\QueuedJob;
use OCA\DAV\CardDAV\CardDavBackend;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\IJobList;
use OCP\IDBConnection;
use OCP\ILogger;
class BuildSocialSearchIndexBackgroundJob extends QueuedJob {
/** @var IDBConnection */
private $db;
/** @var CardDavBackend */
private $davBackend;
/** @var ILogger */
private $logger;
/** @var IJobList */
private $jobList;
/** @var ITimeFactory */
private $timeFactory;
/**
* @param IDBConnection $db
* @param CardDavBackend $davBackend
* @param ILogger $logger
* @param IJobList $jobList
* @param ITimeFactory $timeFactory
*/
public function __construct(IDBConnection $db,
CardDavBackend $davBackend,
ILogger $logger,
IJobList $jobList,
ITimeFactory $timeFactory) {
$this->db = $db;
$this->davBackend = $davBackend;
$this->logger = $logger;
$this->jobList = $jobList;
$this->timeFactory = $timeFactory;
}
public function run($arguments) {
$offset = $arguments['offset'];
$stopAt = $arguments['stopAt'];
$this->logger->info('Indexing social profile data (' . $offset .'/' . $stopAt . ')');
$offset = $this->buildIndex($offset, $stopAt);
if ($offset >= $stopAt) {
$this->logger->info('All contacts with social profiles indexed');
} else {
$this->jobList->add(self::class, [
'offset' => $offset,
'stopAt' => $stopAt
]);
$this->logger->info('New social profile indexing job scheduled with offset ' . $offset);
}
}
/**
* @param int $offset
* @param int $stopAt
* @return int
*/
private function buildIndex($offset, $stopAt) {
$startTime = $this->timeFactory->getTime();
// get contacts with social profiles
$query = $this->db->getQueryBuilder();
$query->select('id', 'addressbookid', 'uri', 'carddata')
->from('cards', 'c')
->orderBy('id', 'ASC')
->where($query->expr()->like('carddata', $query->createNamedParameter('%SOCIALPROFILE%')))
->setMaxResults(100);
$social_cards = $query->execute()->fetchAll();
if (empty($social_cards)) {
return $stopAt;
}
// refresh identified contacts in order to re-index
foreach ($social_cards as $contact) {
$offset = $contact['id'];
$this->davBackend->updateCard($contact['addressbookid'], $contact['uri'], $contact['carddata']);
// stop after 15sec (to be continued with next chunk)
if (($this->timeFactory->getTime() - $startTime) > 15) {
break;
}
}
return $offset;
}
}
@@ -0,0 +1,146 @@
<?php
/**
* @copyright 2017 Joas Schilling <coding@schilljs.com>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Joas Schilling <coding@schilljs.com>
* @author Julius Härtl <jus@bitgrid.net>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\Migration;
use Doctrine\DBAL\Platforms\OraclePlatform;
use OCA\DAV\CalDAV\CalDavBackend;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;
use Psr\Log\LoggerInterface;
use Sabre\VObject\InvalidDataException;
class CalDAVRemoveEmptyValue implements IRepairStep {
/** @var IDBConnection */
private $db;
/** @var CalDavBackend */
private $calDavBackend;
private LoggerInterface $logger;
public function __construct(IDBConnection $db, CalDavBackend $calDavBackend, LoggerInterface $logger) {
$this->db = $db;
$this->calDavBackend = $calDavBackend;
$this->logger = $logger;
}
public function getName() {
return 'Fix broken values of calendar objects';
}
public function run(IOutput $output) {
$pattern = ';VALUE=:';
$count = $warnings = 0;
$objects = $this->getInvalidObjects($pattern);
$output->startProgress(count($objects));
foreach ($objects as $row) {
$calObject = $this->calDavBackend->getCalendarObject((int)$row['calendarid'], $row['uri']);
$data = preg_replace('/' . $pattern . '/', ':', $calObject['calendardata']);
if ($data !== $calObject['calendardata']) {
$output->advance();
try {
$this->calDavBackend->getDenormalizedData($data);
} catch (InvalidDataException $e) {
$this->logger->info('Calendar object for calendar {cal} with uri {uri} still invalid', [
'app' => 'dav',
'cal' => (int)$row['calendarid'],
'uri' => $row['uri'],
]);
$warnings++;
continue;
}
$this->calDavBackend->updateCalendarObject((int)$row['calendarid'], $row['uri'], $data);
$count++;
}
}
$output->finishProgress();
if ($warnings > 0) {
$output->warning(sprintf('%d events could not be updated, see log file for more information', $warnings));
}
if ($count > 0) {
$output->info(sprintf('Updated %d events', $count));
}
}
protected function getInvalidObjects($pattern) {
if ($this->db->getDatabasePlatform() instanceof OraclePlatform) {
$rows = [];
$chunkSize = 500;
$query = $this->db->getQueryBuilder();
$query->select($query->func()->count('*', 'num_entries'))
->from('calendarobjects');
$result = $query->execute();
$count = $result->fetchOne();
$result->closeCursor();
$numChunks = ceil($count / $chunkSize);
$query = $this->db->getQueryBuilder();
$query->select(['calendarid', 'uri', 'calendardata'])
->from('calendarobjects')
->setMaxResults($chunkSize);
for ($chunk = 0; $chunk < $numChunks; $chunk++) {
$query->setFirstResult($chunk * $chunkSize);
$result = $query->execute();
while ($row = $result->fetch()) {
if (mb_strpos($row['calendardata'], $pattern) !== false) {
unset($row['calendardata']);
$rows[] = $row;
}
}
$result->closeCursor();
}
return $rows;
}
$query = $this->db->getQueryBuilder();
$query->select(['calendarid', 'uri'])
->from('calendarobjects')
->where($query->expr()->like(
'calendardata',
$query->createNamedParameter(
'%' . $this->db->escapeLikeParameter($pattern) . '%',
IQueryBuilder::PARAM_STR
),
IQueryBuilder::PARAM_STR
));
$result = $query->execute();
$rows = $result->fetchAll();
$result->closeCursor();
return $rows;
}
}
@@ -0,0 +1,95 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2018, Roeland Jago Douma <roeland@famdouma.nl>
*
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\Migration;
use OCA\DAV\BackgroundJob\UploadCleanup;
use OCP\BackgroundJob\IJobList;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
use OCP\IConfig;
use OCP\IUser;
use OCP\IUserManager;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;
class ChunkCleanup implements IRepairStep {
/** @var IConfig */
private $config;
/** @var IUserManager */
private $userManager;
/** @var IRootFolder */
private $rootFolder;
/** @var IJobList */
private $jobList;
public function __construct(IConfig $config,
IUserManager $userManager,
IRootFolder $rootFolder,
IJobList $jobList) {
$this->config = $config;
$this->userManager = $userManager;
$this->rootFolder = $rootFolder;
$this->jobList = $jobList;
}
public function getName(): string {
return 'Chunk cleanup scheduler';
}
public function run(IOutput $output) {
// If we already ran this onec there is no need to run it again
if ($this->config->getAppValue('dav', 'chunks_migrated', '0') === '1') {
$output->info('Cleanup not required');
}
$output->startProgress();
// Loop over all seen users
$this->userManager->callForSeenUsers(function (IUser $user) use ($output) {
try {
$userFolder = $this->rootFolder->getUserFolder($user->getUID());
$userRoot = $userFolder->getParent();
/** @var Folder $uploadFolder */
$uploadFolder = $userRoot->get('uploads');
} catch (NotFoundException $e) {
// No folder so skipping
return;
}
// Insert a cleanup job for each folder we find
$uploads = $uploadFolder->getDirectoryListing();
foreach ($uploads as $upload) {
$this->jobList->add(UploadCleanup::class, ['uid' => $user->getUID(), 'folder' => $upload->getName()]);
}
$output->advance();
});
$output->finishProgress();
$this->config->setAppValue('dav', 'chunks_migrated', '1');
}
}
@@ -0,0 +1,62 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud GmbH.
*
* @author Thomas Müller <thomas.mueller@tmit.eu>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OCA\DAV\Migration;
use OCA\DAV\CalDAV\BirthdayService;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;
class FixBirthdayCalendarComponent implements IRepairStep {
/** @var IDBConnection */
private $connection;
/**
* FixBirthdayCalendarComponent constructor.
*
* @param IDBConnection $connection
*/
public function __construct(IDBConnection $connection) {
$this->connection = $connection;
}
/**
* @inheritdoc
*/
public function getName() {
return 'Fix component of birthday calendars';
}
/**
* @inheritdoc
*/
public function run(IOutput $output) {
$query = $this->connection->getQueryBuilder();
$updated = $query->update('calendars')
->set('components', $query->createNamedParameter('VEVENT'))
->where($query->expr()->eq('uri', $query->createNamedParameter(BirthdayService::BIRTHDAY_CALENDAR_URI)))
->execute();
$output->info("$updated birthday calendars updated.");
}
}
@@ -0,0 +1,85 @@
<?php
declare(strict_types=1);
/**
* @copyright 2018 Georg Ehrke <oc.list@georgehrke.com>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Georg Ehrke <oc.list@georgehrke.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\Migration;
use OCA\DAV\BackgroundJob\RefreshWebcalJob;
use OCP\BackgroundJob\IJobList;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;
class RefreshWebcalJobRegistrar implements IRepairStep {
/** @var IDBConnection */
private $connection;
/** @var IJobList */
private $jobList;
/**
* FixBirthdayCalendarComponent constructor.
*
* @param IDBConnection $connection
* @param IJobList $jobList
*/
public function __construct(IDBConnection $connection, IJobList $jobList) {
$this->connection = $connection;
$this->jobList = $jobList;
}
/**
* @inheritdoc
*/
public function getName() {
return 'Registering background jobs to update cache for webcal calendars';
}
/**
* @inheritdoc
*/
public function run(IOutput $output) {
$query = $this->connection->getQueryBuilder();
$query->select(['principaluri', 'uri'])
->from('calendarsubscriptions');
$stmt = $query->execute();
$count = 0;
while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
$args = [
'principaluri' => $row['principaluri'],
'uri' => $row['uri'],
];
if (!$this->jobList->has(RefreshWebcalJob::class, $args)) {
$this->jobList->add(RefreshWebcalJob::class, $args);
$count++;
}
}
$output->info("Added $count background jobs to update webcal calendars");
}
}
@@ -0,0 +1,73 @@
<?php
/**
* @copyright 2019 Georg Ehrke <oc.list@georgehrke.com>
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
* @author Georg Ehrke <oc.list@georgehrke.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\Migration;
use OCA\DAV\BackgroundJob\RegisterRegenerateBirthdayCalendars;
use OCP\BackgroundJob\IJobList;
use OCP\IConfig;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;
class RegenerateBirthdayCalendars implements IRepairStep {
/** @var IJobList */
private $jobList;
/** @var IConfig */
private $config;
/**
* @param IJobList $jobList
* @param IConfig $config
*/
public function __construct(IJobList $jobList,
IConfig $config) {
$this->jobList = $jobList;
$this->config = $config;
}
/**
* @return string
*/
public function getName() {
return 'Regenerating birthday calendars to use new icons and fix old birthday events without year';
}
/**
* @param IOutput $output
*/
public function run(IOutput $output) {
// only run once
if ($this->config->getAppValue('dav', 'regeneratedBirthdayCalendarsForYearFix') === 'yes') {
$output->info('Repair step already executed');
return;
}
$output->info('Adding background jobs to regenerate birthday calendar');
$this->jobList->add(RegisterRegenerateBirthdayCalendars::class);
// if all were done, no need to redo the repair during next upgrade
$this->config->setAppValue('dav', 'regeneratedBirthdayCalendarsForYearFix', 'yes');
}
}
@@ -0,0 +1,103 @@
<?php
declare(strict_types=1);
/**
* @copyright 2019 Georg Ehrke <oc.list@georgehrke.com>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Georg Ehrke <oc.list@georgehrke.com>
* @author Joas Schilling <coding@schilljs.com>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\Migration;
use OCA\DAV\BackgroundJob\BuildReminderIndexBackgroundJob;
use OCP\BackgroundJob\IJobList;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;
/**
* Class RegisterBuildReminderIndexBackgroundJob
*
* @package OCA\DAV\Migration
*/
class RegisterBuildReminderIndexBackgroundJob implements IRepairStep {
/** @var IDBConnection */
private $db;
/** @var IJobList */
private $jobList;
/** @var IConfig */
private $config;
/** @var string */
private const CONFIG_KEY = 'buildCalendarReminderIndex';
/**
* @param IDBConnection $db
* @param IJobList $jobList
* @param IConfig $config
*/
public function __construct(IDBConnection $db,
IJobList $jobList,
IConfig $config) {
$this->db = $db;
$this->jobList = $jobList;
$this->config = $config;
}
/**
* @return string
*/
public function getName() {
return 'Registering building of calendar reminder index as background job';
}
/**
* @param IOutput $output
*/
public function run(IOutput $output) {
// only run once
if ($this->config->getAppValue('dav', self::CONFIG_KEY) === 'yes') {
$output->info('Repair step already executed');
return;
}
$query = $this->db->getQueryBuilder();
$query->select($query->createFunction('MAX(' . $query->getColumnName('id') . ')'))
->from('calendarobjects');
$result = $query->execute();
$maxId = (int) $result->fetchOne();
$result->closeCursor();
$output->info('Add background job');
$this->jobList->add(BuildReminderIndexBackgroundJob::class, [
'offset' => 0,
'stopAt' => $maxId
]);
// if all were done, no need to redo the repair during next upgrade
$this->config->setAppValue('dav', self::CONFIG_KEY, 'yes');
}
}
@@ -0,0 +1,136 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com>
*
* @author Joas Schilling <coding@schilljs.com>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\Migration;
use OCA\DAV\CalDAV\CalDavBackend;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;
class RemoveClassifiedEventActivity implements IRepairStep {
/** @var IDBConnection */
private $connection;
public function __construct(IDBConnection $connection) {
$this->connection = $connection;
}
/**
* @inheritdoc
*/
public function getName() {
return 'Remove activity entries of private events';
}
/**
* @inheritdoc
*/
public function run(IOutput $output) {
if (!$this->connection->tableExists('activity')) {
return;
}
$deletedEvents = $this->removePrivateEventActivity();
$deletedEvents += $this->removeConfidentialUncensoredEventActivity();
$output->info("Removed $deletedEvents activity entries");
}
protected function removePrivateEventActivity(): int {
$deletedEvents = 0;
$delete = $this->connection->getQueryBuilder();
$delete->delete('activity')
->where($delete->expr()->neq('affecteduser', $delete->createParameter('owner')))
->andWhere($delete->expr()->eq('object_type', $delete->createParameter('type')))
->andWhere($delete->expr()->eq('object_id', $delete->createParameter('calendar_id')))
->andWhere($delete->expr()->like('subjectparams', $delete->createParameter('event_uid')));
$query = $this->connection->getQueryBuilder();
$query->select('c.principaluri', 'o.calendarid', 'o.uid')
->from('calendarobjects', 'o')
->leftJoin('o', 'calendars', 'c', $query->expr()->eq('c.id', 'o.calendarid'))
->where($query->expr()->eq('o.classification', $query->createNamedParameter(CalDavBackend::CLASSIFICATION_PRIVATE)));
$result = $query->execute();
while ($row = $result->fetch()) {
if ($row['principaluri'] === null) {
continue;
}
$delete->setParameter('owner', $this->getPrincipal($row['principaluri']))
->setParameter('type', 'calendar')
->setParameter('calendar_id', $row['calendarid'])
->setParameter('event_uid', '%' . $this->connection->escapeLikeParameter('{"id":"' . $row['uid'] . '"') . '%');
$deletedEvents += $delete->execute();
}
$result->closeCursor();
return $deletedEvents;
}
protected function removeConfidentialUncensoredEventActivity(): int {
$deletedEvents = 0;
$delete = $this->connection->getQueryBuilder();
$delete->delete('activity')
->where($delete->expr()->neq('affecteduser', $delete->createParameter('owner')))
->andWhere($delete->expr()->eq('object_type', $delete->createParameter('type')))
->andWhere($delete->expr()->eq('object_id', $delete->createParameter('calendar_id')))
->andWhere($delete->expr()->like('subjectparams', $delete->createParameter('event_uid')))
->andWhere($delete->expr()->notLike('subjectparams', $delete->createParameter('filtered_name')));
$query = $this->connection->getQueryBuilder();
$query->select('c.principaluri', 'o.calendarid', 'o.uid')
->from('calendarobjects', 'o')
->leftJoin('o', 'calendars', 'c', $query->expr()->eq('c.id', 'o.calendarid'))
->where($query->expr()->eq('o.classification', $query->createNamedParameter(CalDavBackend::CLASSIFICATION_CONFIDENTIAL)));
$result = $query->execute();
while ($row = $result->fetch()) {
if ($row['principaluri'] === null) {
continue;
}
$delete->setParameter('owner', $this->getPrincipal($row['principaluri']))
->setParameter('type', 'calendar')
->setParameter('calendar_id', $row['calendarid'])
->setParameter('event_uid', '%' . $this->connection->escapeLikeParameter('{"id":"' . $row['uid'] . '"') . '%')
->setParameter('filtered_name', '%' . $this->connection->escapeLikeParameter('{"id":"' . $row['uid'] . '","name":"Busy"') . '%');
$deletedEvents += $delete->execute();
}
$result->closeCursor();
return $deletedEvents;
}
protected function getPrincipal(string $principalUri): string {
$uri = explode('/', $principalUri);
return array_pop($uri);
}
}
@@ -0,0 +1,145 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2021 Thomas Citharel <nextcloud@tcit.fr>
*
* @author Thomas Citharel <nextcloud@tcit.fr>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\Migration;
use OCP\DB\Exception;
use OCP\IDBConnection;
use OCP\IUserManager;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;
class RemoveDeletedUsersCalendarSubscriptions implements IRepairStep {
/** @var IDBConnection */
private $connection;
/** @var IUserManager */
private $userManager;
/** @var int */
private $progress = 0;
/** @var int[] */
private $orphanSubscriptionIds = [];
private const SUBSCRIPTIONS_CHUNK_SIZE = 1000;
public function __construct(IDBConnection $connection, IUserManager $userManager) {
$this->connection = $connection;
$this->userManager = $userManager;
}
/**
* @inheritdoc
*/
public function getName(): string {
return 'Clean up old calendar subscriptions from deleted users that were not cleaned-up';
}
/**
* @inheritdoc
*/
public function run(IOutput $output) {
$nbSubscriptions = $this->countSubscriptions();
$output->startProgress($nbSubscriptions);
while ($this->progress < $nbSubscriptions) {
$this->checkSubscriptions();
$this->progress += self::SUBSCRIPTIONS_CHUNK_SIZE;
$output->advance(min(self::SUBSCRIPTIONS_CHUNK_SIZE, $nbSubscriptions));
}
$output->finishProgress();
$this->deleteOrphanSubscriptions();
$output->info(sprintf('%d calendar subscriptions without an user have been cleaned up', count($this->orphanSubscriptionIds)));
}
/**
* @throws Exception
*/
private function countSubscriptions(): int {
$qb = $this->connection->getQueryBuilder();
$query = $qb->select($qb->func()->count('*'))
->from('calendarsubscriptions');
$result = $query->execute();
$count = $result->fetchOne();
$result->closeCursor();
if ($count !== false) {
$count = (int)$count;
} else {
$count = 0;
}
return $count;
}
/**
* @throws Exception
*/
private function checkSubscriptions(): void {
$qb = $this->connection->getQueryBuilder();
$query = $qb->selectDistinct(['id', 'principaluri'])
->from('calendarsubscriptions')
->setMaxResults(self::SUBSCRIPTIONS_CHUNK_SIZE)
->setFirstResult($this->progress);
$result = $query->execute();
while ($row = $result->fetch()) {
$username = $this->getPrincipal($row['principaluri']);
if (!$this->userManager->userExists($username)) {
$this->orphanSubscriptionIds[] = (int) $row['id'];
}
}
$result->closeCursor();
}
/**
* @throws Exception
*/
private function deleteOrphanSubscriptions(): void {
foreach ($this->orphanSubscriptionIds as $orphanSubscriptionID) {
$this->deleteOrphanSubscription($orphanSubscriptionID);
}
}
/**
* @throws Exception
*/
private function deleteOrphanSubscription(int $orphanSubscriptionID): void {
$qb = $this->connection->getQueryBuilder();
$qb->delete('calendarsubscriptions')
->where($qb->expr()->eq('id', $qb->createNamedParameter($orphanSubscriptionID)))
->executeStatement();
}
private function getPrincipal(string $principalUri): string {
$uri = explode('/', $principalUri);
return array_pop($uri);
}
}
@@ -0,0 +1,65 @@
<?php
/**
* @copyright Copyright (c) 2021, Thomas Citharel <nextcloud@tcit.fr>.
*
* @author Thomas Citharel <nextcloud@tcit.fr>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OCA\DAV\Migration;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;
class RemoveObjectProperties implements IRepairStep {
private const RESOURCE_TYPE_PROPERTY = '{DAV:}resourcetype';
private const ME_CARD_PROPERTY = '{http://calendarserver.org/ns/}me-card';
private const CALENDAR_TRANSP_PROPERTY = '{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp';
/** @var IDBConnection */
private $connection;
/**
* RemoveObjectProperties constructor.
*
* @param IDBConnection $connection
*/
public function __construct(IDBConnection $connection) {
$this->connection = $connection;
}
/**
* @inheritdoc
*/
public function getName() {
return 'Remove invalid object properties';
}
/**
* @inheritdoc
*/
public function run(IOutput $output) {
$query = $this->connection->getQueryBuilder();
$updated = $query->delete('properties')
->where($query->expr()->in('propertyname', $query->createNamedParameter([self::RESOURCE_TYPE_PROPERTY, self::ME_CARD_PROPERTY, self::CALENDAR_TRANSP_PROPERTY], IQueryBuilder::PARAM_STR_ARRAY)))
->andWhere($query->expr()->eq('propertyvalue', $query->createNamedParameter('Object'), IQueryBuilder::PARAM_STR))
->executeStatement();
$output->info("$updated invalid object properties removed.");
}
}
@@ -0,0 +1,110 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Joas Schilling <coding@schilljs.com>
* @author Thomas Citharel <nextcloud@tcit.fr>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\Migration;
use OCA\DAV\CalDAV\CalDavBackend;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;
class RemoveOrphanEventsAndContacts implements IRepairStep {
/** @var IDBConnection */
private $connection;
public function __construct(IDBConnection $connection) {
$this->connection = $connection;
}
/**
* @inheritdoc
*/
public function getName(): string {
return 'Clean up orphan event and contact data';
}
/**
* @inheritdoc
*/
public function run(IOutput $output) {
$orphanItems = $this->removeOrphanChildren('calendarobjects', 'calendars', 'calendarid');
$output->info(sprintf('%d events without a calendar have been cleaned up', $orphanItems));
$orphanItems = $this->removeOrphanChildren('calendarobjects_props', 'calendarobjects', 'objectid');
$output->info(sprintf('%d properties without an events have been cleaned up', $orphanItems));
$orphanItems = $this->removeOrphanChildren('calendarchanges', 'calendars', 'calendarid');
$output->info(sprintf('%d changes without a calendar have been cleaned up', $orphanItems));
$orphanItems = $this->removeOrphanChildren('calendarobjects', 'calendarsubscriptions', 'calendarid');
$output->info(sprintf('%d cached events without a calendar subscription have been cleaned up', $orphanItems));
$orphanItems = $this->removeOrphanChildren('calendarchanges', 'calendarsubscriptions', 'calendarid');
$output->info(sprintf('%d changes without a calendar subscription have been cleaned up', $orphanItems));
$orphanItems = $this->removeOrphanChildren('cards', 'addressbooks', 'addressbookid');
$output->info(sprintf('%d contacts without an addressbook have been cleaned up', $orphanItems));
$orphanItems = $this->removeOrphanChildren('cards_properties', 'cards', 'cardid');
$output->info(sprintf('%d properties without a contact have been cleaned up', $orphanItems));
$orphanItems = $this->removeOrphanChildren('addressbookchanges', 'addressbooks', 'addressbookid');
$output->info(sprintf('%d changes without an addressbook have been cleaned up', $orphanItems));
}
protected function removeOrphanChildren($childTable, $parentTable, $parentId): int {
$qb = $this->connection->getQueryBuilder();
$qb->select('c.id')
->from($childTable, 'c')
->leftJoin('c', $parentTable, 'p', $qb->expr()->eq('c.' . $parentId, 'p.id'))
->where($qb->expr()->isNull('p.id'));
if (\in_array($parentTable, ['calendars', 'calendarsubscriptions'], true)) {
$calendarType = $parentTable === 'calendarsubscriptions' ? CalDavBackend::CALENDAR_TYPE_SUBSCRIPTION : CalDavBackend::CALENDAR_TYPE_CALENDAR;
$qb->andWhere($qb->expr()->eq('c.calendartype', $qb->createNamedParameter($calendarType, IQueryBuilder::PARAM_INT), IQueryBuilder::PARAM_INT));
}
$result = $qb->execute();
$orphanItems = [];
while ($row = $result->fetch()) {
$orphanItems[] = (int) $row['id'];
}
$result->closeCursor();
if (!empty($orphanItems)) {
$qb->delete($childTable)
->where($qb->expr()->in('id', $qb->createParameter('ids')));
$orphanItemsBatch = array_chunk($orphanItems, 200);
foreach ($orphanItemsBatch as $items) {
$qb->setParameter('ids', $items, IQueryBuilder::PARAM_INT_ARRAY);
$qb->execute();
}
}
return count($orphanItems);
}
}
@@ -0,0 +1,496 @@
<?php
/**
* @copyright 2017, Roeland Jago Douma <roeland@famdouma.nl>
*
* @author Georg Ehrke <oc.list@georgehrke.com>
* @author Joas Schilling <coding@schilljs.com>
* @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Vincent Petry <vincent@nextcloud.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\Migration;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
class Version1004Date20170825134824 extends SimpleMigrationStep {
/**
* @param IOutput $output
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @return null|ISchemaWrapper
* @since 13.0.0
*/
public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
if (!$schema->hasTable('addressbooks')) {
$table = $schema->createTable('addressbooks');
$table->addColumn('id', 'bigint', [
'autoincrement' => true,
'notnull' => true,
'length' => 11,
'unsigned' => true,
]);
$table->addColumn('principaluri', 'string', [
'notnull' => false,
'length' => 255,
]);
$table->addColumn('displayname', 'string', [
'notnull' => false,
'length' => 255,
]);
$table->addColumn('uri', 'string', [
'notnull' => false,
'length' => 255,
]);
$table->addColumn('description', 'string', [
'notnull' => false,
'length' => 255,
]);
$table->addColumn('synctoken', 'integer', [
'notnull' => true,
'default' => 1,
'length' => 10,
'unsigned' => true,
]);
$table->setPrimaryKey(['id']);
$table->addUniqueIndex(['principaluri', 'uri'], 'addressbook_index');
}
if (!$schema->hasTable('cards')) {
$table = $schema->createTable('cards');
$table->addColumn('id', 'bigint', [
'autoincrement' => true,
'notnull' => true,
'length' => 11,
'unsigned' => true,
]);
$table->addColumn('addressbookid', 'integer', [
'notnull' => true,
'default' => 0,
]);
$table->addColumn('carddata', 'blob', [
'notnull' => false,
]);
$table->addColumn('uri', 'string', [
'notnull' => false,
'length' => 255,
]);
$table->addColumn('lastmodified', 'bigint', [
'notnull' => false,
'length' => 11,
'unsigned' => true,
]);
$table->addColumn('etag', 'string', [
'notnull' => false,
'length' => 32,
]);
$table->addColumn('size', 'bigint', [
'notnull' => true,
'length' => 11,
'unsigned' => true,
]);
$table->setPrimaryKey(['id']);
}
if (!$schema->hasTable('addressbookchanges')) {
$table = $schema->createTable('addressbookchanges');
$table->addColumn('id', 'bigint', [
'autoincrement' => true,
'notnull' => true,
'length' => 11,
'unsigned' => true,
]);
$table->addColumn('uri', 'string', [
'notnull' => false,
'length' => 255,
]);
$table->addColumn('synctoken', 'integer', [
'notnull' => true,
'default' => 1,
'length' => 10,
'unsigned' => true,
]);
$table->addColumn('addressbookid', 'integer', [
'notnull' => true,
]);
$table->addColumn('operation', 'smallint', [
'notnull' => true,
'length' => 1,
]);
$table->setPrimaryKey(['id']);
$table->addIndex(['addressbookid', 'synctoken'], 'addressbookid_synctoken');
}
if (!$schema->hasTable('calendarobjects')) {
$table = $schema->createTable('calendarobjects');
$table->addColumn('id', 'bigint', [
'autoincrement' => true,
'notnull' => true,
'length' => 11,
'unsigned' => true,
]);
$table->addColumn('calendardata', 'blob', [
'notnull' => false,
]);
$table->addColumn('uri', 'string', [
'notnull' => false,
'length' => 255,
]);
$table->addColumn('calendarid', 'integer', [
'notnull' => true,
'length' => 10,
'unsigned' => true,
]);
$table->addColumn('lastmodified', 'integer', [
'notnull' => false,
'length' => 10,
'unsigned' => true,
]);
$table->addColumn('etag', 'string', [
'notnull' => false,
'length' => 32,
]);
$table->addColumn('size', 'bigint', [
'notnull' => true,
'length' => 11,
'unsigned' => true,
]);
$table->addColumn('componenttype', 'string', [
'notnull' => false,
'length' => 8,
]);
$table->addColumn('firstoccurence', 'bigint', [
'notnull' => false,
'length' => 11,
'unsigned' => true,
]);
$table->addColumn('lastoccurence', 'bigint', [
'notnull' => false,
'length' => 11,
'unsigned' => true,
]);
$table->addColumn('uid', 'string', [
'notnull' => false,
'length' => 255,
]);
$table->addColumn('classification', 'integer', [
'notnull' => false,
'default' => 0,
]);
$table->setPrimaryKey(['id']);
$table->addUniqueIndex(['calendarid', 'uri'], 'calobjects_index');
}
if (!$schema->hasTable('calendars')) {
$table = $schema->createTable('calendars');
$table->addColumn('id', 'bigint', [
'autoincrement' => true,
'notnull' => true,
'length' => 11,
'unsigned' => true,
]);
$table->addColumn('principaluri', 'string', [
'notnull' => false,
'length' => 255,
]);
$table->addColumn('displayname', 'string', [
'notnull' => false,
'length' => 255,
]);
$table->addColumn('uri', 'string', [
'notnull' => false,
'length' => 255,
]);
$table->addColumn('synctoken', 'integer', [
'notnull' => true,
'default' => 1,
'unsigned' => true,
]);
$table->addColumn('description', 'string', [
'notnull' => false,
'length' => 255,
]);
$table->addColumn('calendarorder', 'integer', [
'notnull' => true,
'default' => 0,
'unsigned' => true,
]);
$table->addColumn('calendarcolor', 'string', [
'notnull' => false,
]);
$table->addColumn('timezone', 'text', [
'notnull' => false,
]);
$table->addColumn('components', 'string', [
'notnull' => false,
'length' => 64,
]);
$table->addColumn('transparent', 'smallint', [
'notnull' => true,
'length' => 1,
'default' => 0,
]);
$table->setPrimaryKey(['id']);
$table->addUniqueIndex(['principaluri', 'uri'], 'calendars_index');
} else {
$table = $schema->getTable('calendars');
$table->changeColumn('components', [
'notnull' => false,
'length' => 64,
]);
}
if (!$schema->hasTable('calendarchanges')) {
$table = $schema->createTable('calendarchanges');
$table->addColumn('id', 'bigint', [
'autoincrement' => true,
'notnull' => true,
'length' => 11,
'unsigned' => true,
]);
$table->addColumn('uri', 'string', [
'notnull' => false,
'length' => 255,
]);
$table->addColumn('synctoken', 'integer', [
'notnull' => true,
'default' => 1,
'length' => 10,
'unsigned' => true,
]);
$table->addColumn('calendarid', 'integer', [
'notnull' => true,
]);
$table->addColumn('operation', 'smallint', [
'notnull' => true,
'length' => 1,
]);
$table->setPrimaryKey(['id']);
$table->addIndex(['calendarid', 'synctoken'], 'calendarid_synctoken');
}
if (!$schema->hasTable('calendarsubscriptions')) {
$table = $schema->createTable('calendarsubscriptions');
$table->addColumn('id', 'bigint', [
'autoincrement' => true,
'notnull' => true,
'length' => 11,
'unsigned' => true,
]);
$table->addColumn('uri', 'string', [
'notnull' => false,
]);
$table->addColumn('principaluri', 'string', [
'notnull' => false,
'length' => 255,
]);
$table->addColumn('source', 'string', [
'notnull' => false,
'length' => 255,
]);
$table->addColumn('displayname', 'string', [
'notnull' => false,
'length' => 100,
]);
$table->addColumn('refreshrate', 'string', [
'notnull' => false,
'length' => 10,
]);
$table->addColumn('calendarorder', 'integer', [
'notnull' => true,
'default' => 0,
'unsigned' => true,
]);
$table->addColumn('calendarcolor', 'string', [
'notnull' => false,
]);
$table->addColumn('striptodos', 'smallint', [
'notnull' => false,
'length' => 1,
]);
$table->addColumn('stripalarms', 'smallint', [
'notnull' => false,
'length' => 1,
]);
$table->addColumn('stripattachments', 'smallint', [
'notnull' => false,
'length' => 1,
]);
$table->addColumn('lastmodified', 'integer', [
'notnull' => false,
'unsigned' => true,
]);
$table->setPrimaryKey(['id']);
$table->addUniqueIndex(['principaluri', 'uri'], 'calsub_index');
} else {
$table = $schema->getTable('calendarsubscriptions');
$table->changeColumn('lastmodified', [
'notnull' => false,
'unsigned' => true,
]);
}
if (!$schema->hasTable('schedulingobjects')) {
$table = $schema->createTable('schedulingobjects');
$table->addColumn('id', 'bigint', [
'autoincrement' => true,
'notnull' => true,
'length' => 11,
'unsigned' => true,
]);
$table->addColumn('principaluri', 'string', [
'notnull' => false,
'length' => 255,
]);
$table->addColumn('calendardata', 'blob', [
'notnull' => false,
]);
$table->addColumn('uri', 'string', [
'notnull' => false,
'length' => 255,
]);
$table->addColumn('lastmodified', 'integer', [
'notnull' => false,
'unsigned' => true,
]);
$table->addColumn('etag', 'string', [
'notnull' => false,
'length' => 32,
]);
$table->addColumn('size', 'bigint', [
'notnull' => true,
'length' => 11,
'unsigned' => true,
]);
$table->setPrimaryKey(['id']);
$table->addIndex(['principaluri'], 'schedulobj_principuri_index');
}
if (!$schema->hasTable('cards_properties')) {
$table = $schema->createTable('cards_properties');
$table->addColumn('id', 'bigint', [
'autoincrement' => true,
'notnull' => true,
'length' => 11,
'unsigned' => true,
]);
$table->addColumn('addressbookid', 'bigint', [
'notnull' => true,
'length' => 11,
'default' => 0,
]);
$table->addColumn('cardid', 'bigint', [
'notnull' => true,
'length' => 11,
'default' => 0,
'unsigned' => true,
]);
$table->addColumn('name', 'string', [
'notnull' => false,
'length' => 64,
]);
$table->addColumn('value', 'string', [
'notnull' => false,
'length' => 255,
]);
$table->addColumn('preferred', 'integer', [
'notnull' => true,
'length' => 4,
'default' => 1,
]);
$table->setPrimaryKey(['id']);
$table->addIndex(['cardid'], 'card_contactid_index');
$table->addIndex(['name'], 'card_name_index');
$table->addIndex(['value'], 'card_value_index');
}
if (!$schema->hasTable('calendarobjects_props')) {
$table = $schema->createTable('calendarobjects_props');
$table->addColumn('id', 'bigint', [
'autoincrement' => true,
'notnull' => true,
'length' => 11,
'unsigned' => true,
]);
$table->addColumn('calendarid', 'bigint', [
'notnull' => true,
'length' => 11,
'default' => 0,
]);
$table->addColumn('objectid', 'bigint', [
'notnull' => true,
'length' => 11,
'default' => 0,
'unsigned' => true,
]);
$table->addColumn('name', 'string', [
'notnull' => false,
'length' => 64,
]);
$table->addColumn('parameter', 'string', [
'notnull' => false,
'length' => 64,
]);
$table->addColumn('value', 'string', [
'notnull' => false,
'length' => 255,
]);
$table->setPrimaryKey(['id']);
$table->addIndex(['objectid'], 'calendarobject_index');
$table->addIndex(['name'], 'calendarobject_name_index');
$table->addIndex(['value'], 'calendarobject_value_index');
}
if (!$schema->hasTable('dav_shares')) {
$table = $schema->createTable('dav_shares');
$table->addColumn('id', 'bigint', [
'autoincrement' => true,
'notnull' => true,
'length' => 11,
'unsigned' => true,
]);
$table->addColumn('principaluri', 'string', [
'notnull' => false,
'length' => 255,
]);
$table->addColumn('type', 'string', [
'notnull' => false,
'length' => 255,
]);
$table->addColumn('access', 'smallint', [
'notnull' => false,
'length' => 1,
]);
$table->addColumn('resourceid', 'integer', [
'notnull' => true,
'unsigned' => true,
]);
$table->addColumn('publicuri', 'string', [
'notnull' => false,
'length' => 255,
]);
$table->setPrimaryKey(['id']);
$table->addUniqueIndex(['principaluri', 'resourceid', 'type', 'publicuri'], 'dav_shares_index');
}
return $schema;
}
}
@@ -0,0 +1,58 @@
<?php
/**
* @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
*
* @author Joas Schilling <coding@schilljs.com>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\Migration;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
class Version1004Date20170919104507 extends SimpleMigrationStep {
/**
* @param IOutput $output
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @return null|ISchemaWrapper
* @since 13.0.0
*/
public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
$table = $schema->getTable('addressbooks');
$column = $table->getColumn('id');
$column->setUnsigned(true);
$table = $schema->getTable('calendarobjects');
$column = $table->getColumn('id');
$column->setUnsigned(true);
$table = $schema->getTable('calendarchanges');
$column = $table->getColumn('id');
$column->setUnsigned(true);
return $schema;
}
}
@@ -0,0 +1,52 @@
<?php
/**
* @copyright 2017, Roeland Jago Douma <roeland@famdouma.nl>
*
* @author Joas Schilling <coding@schilljs.com>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\Migration;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
class Version1004Date20170924124212 extends SimpleMigrationStep {
/**
* @param IOutput $output
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @return null|ISchemaWrapper
* @since 13.0.0
*/
public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
$table = $schema->getTable('cards');
$table->addIndex(['addressbookid'], 'cards_abid');
$table->addIndex(['addressbookid', 'uri'], 'cards_abiduri');
$table = $schema->getTable('cards_properties');
$table->addIndex(['addressbookid'], 'cards_prop_abid');
return $schema;
}
}
@@ -0,0 +1,53 @@
<?php
/**
* @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
*
* @author Joas Schilling <coding@schilljs.com>
* @author Morris Jobke <hey@morrisjobke.de>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\Migration;
use OCP\Migration\BigIntMigration;
/**
* Auto-generated migration step: Please modify to your needs!
*/
class Version1004Date20170926103422 extends BigIntMigration {
/**
* @return array Returns an array with the following structure
* ['table1' => ['column1', 'column2'], ...]
* @since 13.0.0
*/
protected function getColumnsByTable() {
return [
'addressbooks' => ['id'],
'addressbookchanges' => ['id', 'addressbookid'],
'calendars' => ['id'],
'calendarchanges' => ['id', 'calendarid'],
'calendarobjects' => ['id', 'calendarid'],
'calendarobjects_props' => ['id', 'calendarid', 'objectid'],
'calendarsubscriptions' => ['id'],
'cards' => ['id', 'addressbookid'],
'cards_properties' => ['id', 'addressbookid', 'cardid'],
'dav_shares' => ['id', 'resourceid'],
'schedulingobjects' => ['id'],
];
}
}
@@ -0,0 +1,83 @@
<?php
declare(strict_types=1);
/**
* @copyright 2018, Roeland Jago Douma <roeland@famdouma.nl>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Daniel Kesselberg <mail@danielkesselberg.de>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\Migration;
use OCP\DB\ISchemaWrapper;
use OCP\DB\Types;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
class Version1005Date20180413093149 extends SimpleMigrationStep {
/**
* @param IOutput $output
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @return null|ISchemaWrapper
*/
public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
if (!$schema->hasTable('directlink')) {
$table = $schema->createTable('directlink');
$table->addColumn('id', Types::BIGINT, [
'autoincrement' => true,
'notnull' => true,
'length' => 11,
'unsigned' => true,
]);
$table->addColumn('user_id', Types::STRING, [
'notnull' => false,
'length' => 64,
]);
$table->addColumn('file_id', Types::BIGINT, [
'notnull' => true,
'length' => 11,
'unsigned' => true,
]);
$table->addColumn('token', Types::STRING, [
'notnull' => false,
'length' => 60,
]);
$table->addColumn('expiration', Types::BIGINT, [
'notnull' => true,
'length' => 11,
'unsigned' => true,
]);
$table->setPrimaryKey(['id'], 'directlink_id_idx');
$table->addIndex(['token'], 'directlink_token_idx');
$table->addIndex(['expiration'], 'directlink_expiration_idx');
return $schema;
}
}
}
@@ -0,0 +1,88 @@
<?php
/**
* @copyright 2017 Georg Ehrke <oc.list@georgehrke.com>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Daniel Kesselberg <mail@danielkesselberg.de>
* @author Georg Ehrke <oc.list@georgehrke.com>
* @author Joas Schilling <coding@schilljs.com>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\Migration;
use OCP\DB\ISchemaWrapper;
use OCP\DB\Types;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
class Version1005Date20180530124431 extends SimpleMigrationStep {
/**
* @param IOutput $output
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @return null|ISchemaWrapper
* @since 13.0.0
*/
public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
$types = ['resources', 'rooms'];
foreach ($types as $type) {
if (!$schema->hasTable('calendar_' . $type)) {
$table = $schema->createTable('calendar_' . $type);
$table->addColumn('id', Types::BIGINT, [
'autoincrement' => true,
'notnull' => true,
'length' => 11,
'unsigned' => true,
]);
$table->addColumn('backend_id', Types::STRING, [
'notnull' => false,
'length' => 64,
]);
$table->addColumn('resource_id', Types::STRING, [
'notnull' => false,
'length' => 64,
]);
$table->addColumn('email', Types::STRING, [
'notnull' => false,
'length' => 255,
]);
$table->addColumn('displayname', Types::STRING, [
'notnull' => false,
'length' => 255,
]);
$table->addColumn('group_restrictions', Types::STRING, [
'notnull' => false,
'length' => 4000,
]);
$table->setPrimaryKey(['id']);
$table->addIndex(['backend_id', 'resource_id'], 'calendar_' . $type . '_bkdrsc');
$table->addIndex(['email'], 'calendar_' . $type . '_email');
$table->addIndex(['displayname'], 'calendar_' . $type . '_name');
}
}
return $schema;
}
}
@@ -0,0 +1,96 @@
<?php
/**
* @copyright Copyright (c) 2016 Georg Ehrke <oc.list@georgehrke.com>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Daniel Kesselberg <mail@danielkesselberg.de>
* @author Georg Ehrke <oc.list@georgehrke.com>
* @author Joas Schilling <coding@schilljs.com>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\Migration;
use OCP\DB\ISchemaWrapper;
use OCP\DB\Types;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
/**
* Auto-generated migration step: Please modify to your needs!
*/
class Version1006Date20180619154313 extends SimpleMigrationStep {
/**
* @param IOutput $output
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @return null|ISchemaWrapper
* @since 13.0.0
*/
public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
if (!$schema->hasTable('calendar_invitations')) {
$table = $schema->createTable('calendar_invitations');
$table->addColumn('id', Types::BIGINT, [
'autoincrement' => true,
'notnull' => true,
'length' => 11,
'unsigned' => true,
]);
$table->addColumn('uid', Types::STRING, [
'notnull' => true,
'length' => 255,
]);
$table->addColumn('recurrenceid', Types::STRING, [
'notnull' => false,
'length' => 255,
]);
$table->addColumn('attendee', Types::STRING, [
'notnull' => true,
'length' => 255,
]);
$table->addColumn('organizer', Types::STRING, [
'notnull' => true,
'length' => 255,
]);
$table->addColumn('sequence', Types::BIGINT, [
'notnull' => false,
'length' => 11,
'unsigned' => true,
]);
$table->addColumn('token', Types::STRING, [
'notnull' => true,
'length' => 60,
]);
$table->addColumn('expiration', Types::BIGINT, [
'notnull' => true,
'length' => 11,
'unsigned' => true,
]);
$table->setPrimaryKey(['id']);
$table->addIndex(['token'], 'calendar_invitation_tokens');
return $schema;
}
}
}
@@ -0,0 +1,111 @@
<?php
declare(strict_types=1);
/**
* @copyright 2018 Georg Ehrke <oc.list@georgehrke.com>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Daniel Kesselberg <mail@danielkesselberg.de>
* @author Georg Ehrke <oc.list@georgehrke.com>
* @author Joas Schilling <coding@schilljs.com>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\Migration;
use OCP\DB\ISchemaWrapper;
use OCP\DB\Types;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
class Version1006Date20180628111625 extends SimpleMigrationStep {
/**
* @param IOutput $output
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @return null|ISchemaWrapper
*/
public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
if ($schema->hasTable('calendarchanges')) {
$calendarChangesTable = $schema->getTable('calendarchanges');
$calendarChangesTable->addColumn('calendartype', Types::INTEGER, [
'notnull' => true,
'default' => 0,
]);
if ($calendarChangesTable->hasIndex('calendarid_synctoken')) {
$calendarChangesTable->dropIndex('calendarid_synctoken');
}
$calendarChangesTable->addIndex(['calendarid', 'calendartype', 'synctoken'], 'calid_type_synctoken');
}
if ($schema->hasTable('calendarobjects')) {
$calendarObjectsTable = $schema->getTable('calendarobjects');
$calendarObjectsTable->addColumn('calendartype', Types::INTEGER, [
'notnull' => true,
'default' => 0,
]);
if ($calendarObjectsTable->hasIndex('calobjects_index')) {
$calendarObjectsTable->dropIndex('calobjects_index');
}
$calendarObjectsTable->addUniqueIndex(['calendarid', 'calendartype', 'uri'], 'calobjects_index');
}
if ($schema->hasTable('calendarobjects_props')) {
$calendarObjectsPropsTable = $schema->getTable('calendarobjects_props');
$calendarObjectsPropsTable->addColumn('calendartype', Types::INTEGER, [
'notnull' => true,
'default' => 0,
]);
if ($calendarObjectsPropsTable->hasIndex('calendarobject_index')) {
$calendarObjectsPropsTable->dropIndex('calendarobject_index');
}
if ($calendarObjectsPropsTable->hasIndex('calendarobject_name_index')) {
$calendarObjectsPropsTable->dropIndex('calendarobject_name_index');
}
if ($calendarObjectsPropsTable->hasIndex('calendarobject_value_index')) {
$calendarObjectsPropsTable->dropIndex('calendarobject_value_index');
}
$calendarObjectsPropsTable->addIndex(['objectid', 'calendartype'], 'calendarobject_index');
$calendarObjectsPropsTable->addIndex(['name', 'calendartype'], 'calendarobject_name_index');
$calendarObjectsPropsTable->addIndex(['value', 'calendartype'], 'calendarobject_value_index');
$calendarObjectsPropsTable->addIndex(['calendarid', 'calendartype'], 'calendarobject_calid_index');
}
if ($schema->hasTable('calendarsubscriptions')) {
$calendarSubscriptionsTable = $schema->getTable('calendarsubscriptions');
$calendarSubscriptionsTable->addColumn('synctoken', 'integer', [
'notnull' => true,
'default' => 1,
'length' => 10,
'unsigned' => true,
]);
}
return $schema;
}
}
@@ -0,0 +1,58 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2018, John Molakvoæ (skjnldsv@protonmail.com)
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Daniel Kesselberg <mail@danielkesselberg.de>
* @author John Molakvoæ <skjnldsv@protonmail.com>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\Migration;
use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\DB\Types;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
class Version1008Date20181030113700 extends SimpleMigrationStep {
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @return null|ISchemaWrapper
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
$table = $schema->getTable('cards');
$table->addColumn('uid', Types::STRING, [
'notnull' => false,
'length' => 255
]);
return $schema;
}
}
@@ -0,0 +1,82 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2018 Georg Ehrke
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Daniel Kesselberg <mail@danielkesselberg.de>
* @author Georg Ehrke <oc.list@georgehrke.com>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\Migration;
use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\DB\Types;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
class Version1008Date20181105104826 extends SimpleMigrationStep {
/** @var IDBConnection */
private $connection;
/**
* Version1008Date20181105104826 constructor.
*
* @param IDBConnection $connection
*/
public function __construct(IDBConnection $connection) {
$this->connection = $connection;
}
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @return null|ISchemaWrapper
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
$table = $schema->getTable('calendarsubscriptions');
$table->addColumn('source_copy', Types::TEXT, [
'notnull' => false,
'length' => null,
]);
return $schema;
}
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
*/
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
$qb = $this->connection->getQueryBuilder();
$qb->update('calendarsubscriptions')
->set('source_copy', 'source')
->execute();
}
}
@@ -0,0 +1,50 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2018 Georg Ehrke
*
* @author Georg Ehrke <oc.list@georgehrke.com>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\Migration;
use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
class Version1008Date20181105104833 extends SimpleMigrationStep {
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @return null|ISchemaWrapper
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
$table = $schema->getTable('calendarsubscriptions');
$table->dropColumn('source');
return $schema;
}
}
@@ -0,0 +1,81 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2018 Georg Ehrke
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Daniel Kesselberg <mail@danielkesselberg.de>
* @author Georg Ehrke <oc.list@georgehrke.com>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\Migration;
use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\DB\Types;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
class Version1008Date20181105110300 extends SimpleMigrationStep {
/** @var IDBConnection */
private $connection;
/**
* Version1008Date20181105110300 constructor.
*
* @param IDBConnection $connection
*/
public function __construct(IDBConnection $connection) {
$this->connection = $connection;
}
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @return null|ISchemaWrapper
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
$table = $schema->getTable('calendarsubscriptions');
$table->addColumn('source', Types::TEXT, [
'notnull' => false,
'length' => null,
]);
return $schema;
}
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
*/
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
$qb = $this->connection->getQueryBuilder();
$qb->update('calendarsubscriptions')
->set('source', 'source_copy')
->execute();
}
}
@@ -0,0 +1,50 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2018 Georg Ehrke
*
* @author Georg Ehrke <oc.list@georgehrke.com>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\Migration;
use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
class Version1008Date20181105112049 extends SimpleMigrationStep {
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @return null|ISchemaWrapper
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
$table = $schema->getTable('calendarsubscriptions');
$table->dropColumn('source_copy');
return $schema;
}
}
@@ -0,0 +1,60 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2018, Joas Schilling <coding@schilljs.com>
*
* @author Joas Schilling <coding@schilljs.com>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\Migration;
use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
class Version1008Date20181114084440 extends SimpleMigrationStep {
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @return null|ISchemaWrapper
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
if ($schema->hasTable('calendarchanges')) {
$calendarChangesTable = $schema->getTable('calendarchanges');
if ($calendarChangesTable->hasIndex('calendarid_calendartype_synctoken')) {
$calendarChangesTable->dropIndex('calendarid_calendartype_synctoken');
}
if (!$calendarChangesTable->hasIndex('calid_type_synctoken')) {
$calendarChangesTable->addIndex(['calendarid', 'calendartype', 'synctoken'], 'calid_type_synctoken');
}
}
return $schema;
}
}
@@ -0,0 +1,92 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2016 Georg Ehrke <oc.list@georgehrke.com>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Daniel Kesselberg <mail@danielkesselberg.de>
* @author Georg Ehrke <oc.list@georgehrke.com>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\Migration;
use OCP\DB\ISchemaWrapper;
use OCP\DB\Types;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
/**
* Auto-generated migration step: Please modify to your needs!
*/
class Version1011Date20190725113607 extends SimpleMigrationStep {
/**
* @param IOutput $output
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @return null|ISchemaWrapper
* @since 13.0.0
*/
public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
$types = ['resource', 'room'];
foreach ($types as $type) {
if (!$schema->hasTable($this->getMetadataTableName($type))) {
$table = $schema->createTable($this->getMetadataTableName($type));
$table->addColumn('id', Types::BIGINT, [
'autoincrement' => true,
'notnull' => true,
'length' => 11,
'unsigned' => true,
]);
$table->addColumn($type . '_id', Types::BIGINT, [
'notnull' => true,
'length' => 11,
'unsigned' => true,
]);
$table->addColumn('key', Types::STRING, [
'notnull' => true,
'length' => 255,
]);
$table->addColumn('value', Types::STRING, [
'notnull' => false,
'length' => 4000,
]);
$table->setPrimaryKey(['id']);
$table->addIndex([$type . '_id', 'key'], $this->getMetadataTableName($type) . '_idk');
}
}
return $schema;
}
/**
* @param string $type
* @return string
*/
private function getMetadataTableName(string $type):string {
return 'calendar_' . $type . 's_md';
}
}
@@ -0,0 +1,78 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2016 Roeland Jago Douma <roeland@famdouma.nl>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Daniel Kesselberg <mail@danielkesselberg.de>
* @author Georg Ehrke <oc.list@georgehrke.com>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\Migration;
use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\DB\Types;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
/**
* Auto-generated migration step: Please modify to your needs!
*/
class Version1011Date20190806104428 extends SimpleMigrationStep {
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @return null|ISchemaWrapper
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
$table = $schema->createTable('dav_cal_proxy');
$table->addColumn('id', Types::BIGINT, [
'autoincrement' => true,
'notnull' => true,
'length' => 11,
'unsigned' => true,
]);
$table->addColumn('owner_id', Types::STRING, [
'notnull' => true,
'length' => 64,
]);
$table->addColumn('proxy_id', Types::STRING, [
'notnull' => true,
'length' => 64,
]);
$table->addColumn('permissions', Types::INTEGER, [
'notnull' => false,
'length' => 4,
'unsigned' => true,
]);
$table->setPrimaryKey(['id']);
$table->addUniqueIndex(['owner_id', 'proxy_id', 'permissions'], 'dav_cal_proxy_uidx');
$table->addIndex(['proxy_id'], 'dav_cal_proxy_ipid');
return $schema;
}
}
@@ -0,0 +1,124 @@
<?php
declare(strict_types=1);
/**
* @copyright 2019, Georg Ehrke <oc.list@georgehrke.com>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Daniel Kesselberg <mail@danielkesselberg.de>
* @author Georg Ehrke <oc.list@georgehrke.com>
* @author Joas Schilling <coding@schilljs.com>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\Migration;
use OCP\DB\ISchemaWrapper;
use OCP\DB\Types;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
/**
* Auto-generated migration step: Please modify to your needs!
*/
class Version1012Date20190808122342 extends SimpleMigrationStep {
/**
* @param IOutput $output
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @return null|ISchemaWrapper
* @since 17.0.0
*/
public function changeSchema(IOutput $output,
\Closure $schemaClosure,
array $options):?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
if (!$schema->hasTable('calendar_reminders')) {
$table = $schema->createTable('calendar_reminders');
$table->addColumn('id', Types::BIGINT, [
'autoincrement' => true,
'notnull' => true,
'length' => 11,
'unsigned' => true,
]);
$table->addColumn('calendar_id', Types::BIGINT, [
'notnull' => true,
'length' => 11,
]);
$table->addColumn('object_id', Types::BIGINT, [
'notnull' => true,
'length' => 11,
]);
$table->addColumn('is_recurring', Types::SMALLINT, [
'notnull' => false,
'length' => 1,
]);
$table->addColumn('uid', Types::STRING, [
'notnull' => true,
'length' => 255,
]);
$table->addColumn('recurrence_id', Types::BIGINT, [
'notnull' => false,
'length' => 11,
'unsigned' => true,
]);
$table->addColumn('is_recurrence_exception', Types::SMALLINT, [
'notnull' => true,
'length' => 1,
]);
$table->addColumn('event_hash', Types::STRING, [
'notnull' => true,
'length' => 255,
]);
$table->addColumn('alarm_hash', Types::STRING, [
'notnull' => true,
'length' => 255,
]);
$table->addColumn('type', Types::STRING, [
'notnull' => true,
'length' => 255,
]);
$table->addColumn('is_relative', Types::SMALLINT, [
'notnull' => true,
'length' => 1,
]);
$table->addColumn('notification_date', Types::BIGINT, [
'notnull' => true,
'length' => 11,
'unsigned' => true,
]);
$table->addColumn('is_repeat_based', Types::SMALLINT, [
'notnull' => true,
'length' => 1,
]);
$table->setPrimaryKey(['id']);
$table->addIndex(['object_id'], 'calendar_reminder_objid');
$table->addIndex(['uid', 'recurrence_id'], 'calendar_reminder_uidrec');
return $schema;
}
return null;
}
}
@@ -0,0 +1,60 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2020 Joas Schilling <coding@schilljs.com>
*
* @author Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\Migration;
use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
class Version1016Date20201109085907 extends SimpleMigrationStep {
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @return null|ISchemaWrapper
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
$result = $this->ensureColumnIsNullable($schema, 'calendar_reminders', 'is_recurring');
return $result ? $schema : null;
}
protected function ensureColumnIsNullable(ISchemaWrapper $schema, string $tableName, string $columnName): bool {
$table = $schema->getTable($tableName);
$column = $table->getColumn($columnName);
if ($column->getNotnull()) {
$column->setNotnull(false);
return true;
}
return false;
}
}
@@ -0,0 +1,54 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2021 Roeland Jago Douma <roeland@famdouma.nl>
*
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\Migration;
use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
/**
* Auto-generated migration step: Please modify to your needs!
*/
class Version1017Date20210216083742 extends SimpleMigrationStep {
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @return null|ISchemaWrapper
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
$table = $schema->getTable('dav_cal_proxy');
if ($table->hasIndex('dav_cal_proxy_ioid')) {
$table->dropIndex('dav_cal_proxy_ioid');
}
return $schema;
}
}
@@ -0,0 +1,66 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2016 Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\Migration;
use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\DB\Types;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
class Version1018Date20210312100735 extends SimpleMigrationStep {
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @return ISchemaWrapper
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
$calendarsTable = $schema->getTable('calendars');
$calendarsTable->addColumn('deleted_at', Types::INTEGER, [
'notnull' => false,
'length' => 4,
'unsigned' => true,
]);
$calendarsTable->addIndex([
'principaluri',
'deleted_at',
], 'cals_princ_del_idx');
$calendarObjectsTable = $schema->getTable('calendarobjects');
$calendarObjectsTable->addColumn('deleted_at', Types::INTEGER, [
'notnull' => false,
'length' => 4,
'unsigned' => true,
]);
return $schema;
}
}
@@ -0,0 +1,58 @@
<?php
declare(strict_types=1);
namespace OCA\DAV\Migration;
use Closure;
use Doctrine\DBAL\Schema\SchemaException;
use OCA\DAV\DAV\CustomPropertiesBackend;
use OCP\DB\ISchemaWrapper;
use OCP\DB\Types;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
/**
* Auto-generated migration step: Please modify to your needs!
*/
class Version1024Date20211221144219 extends SimpleMigrationStep {
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
*/
public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
}
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @return null|ISchemaWrapper
* @throws SchemaException
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
$propertiesTable = $schema->getTable('properties');
if ($propertiesTable->hasColumn('valuetype')) {
return null;
}
$propertiesTable->addColumn('valuetype', Types::SMALLINT, [
'notnull' => false,
'default' => CustomPropertiesBackend::PROPERTY_TYPE_STRING
]);
return $schema;
}
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
*/
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
}
}
@@ -0,0 +1,68 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Anna Larch <anna.larch@gmx.net>
*
* @author Anna Larch <anna.larch@gmx.net>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\Migration;
use Closure;
use OCA\DAV\CardDAV\SyncService;
use OCP\DB\ISchemaWrapper;
use OCP\IConfig;
use OCP\IUserManager;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
use Psr\Log\LoggerInterface;
use Throwable;
class Version1027Date20230504122946 extends SimpleMigrationStep {
public function __construct(private SyncService $syncService,
private LoggerInterface $logger,
private IUserManager $userManager,
private IConfig $config) {
}
/**
* @param IOutput $output
* @param Closure(): ISchemaWrapper $schemaClosure
* @param array $options
*/
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
if($this->userManager->countSeenUsers() > 100 || array_sum($this->userManager->countUsers()) > 100) {
$this->config->setAppValue('dav', 'needs_system_address_book_sync', 'yes');
$output->info('Could not sync system address books during update - too many user records have been found. Please call occ dav:sync-system-addressbook manually.');
return;
}
try {
$this->syncService->syncInstance();
$this->config->setAppValue('dav', 'needs_system_address_book_sync', 'no');
} catch (Throwable $e) {
$this->config->setAppValue('dav', 'needs_system_address_book_sync', 'yes');
$this->logger->error('Could not sync system address books during update', [
'exception' => $e,
]);
$output->warning('System address book sync failed. See logs for details');
}
}
}
@@ -0,0 +1,55 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2022 Murena SAS <akhil.potukuchi.ext@murena.com>
*
* @author Murena SAS <akhil.potukuchi.ext@murena.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\Migration;
use Closure;
use Doctrine\DBAL\Schema\SchemaException;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
class Version1029Date20221114151721 extends SimpleMigrationStep {
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @return null|ISchemaWrapper
* @throws SchemaException
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
$calendarObjectsTable = $schema->getTable('calendarobjects');
if(!$calendarObjectsTable->hasIndex('calobj_clssfction_index')) {
$calendarObjectsTable->addIndex(['classification'], 'calobj_clssfction_index');
return $schema;
}
return null;
}
}
@@ -0,0 +1,83 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Richard Steinmetz <richard@steinmetz.cloud>
*
* @author Richard Steinmetz <richard@steinmetz.cloud>
*
* @license AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\Migration;
use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\DB\Types;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
class Version1029Date20231004091403 extends SimpleMigrationStep {
/**
* @param IOutput $output
* @param Closure(): ISchemaWrapper $schemaClosure
* @param array $options
* @return null|ISchemaWrapper
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
if (!$schema->hasTable('dav_absence')) {
$table = $schema->createTable('dav_absence');
$table->addColumn('id', Types::INTEGER, [
'autoincrement' => true,
'notnull' => true,
'length' => 4,
]);
$table->addColumn('user_id', Types::STRING, [
'notnull' => true,
'length' => 64,
]);
$table->addColumn('first_day', Types::STRING, [
'length' => 10,
'notnull' => true,
]);
$table->addColumn('last_day', Types::STRING, [
'length' => 10,
'notnull' => true,
]);
$table->addColumn('status', Types::STRING, [
'length' => 100,
'notnull' => true,
]);
$table->addColumn('message', Types::TEXT, [
'notnull' => true,
]);
$table->addUniqueIndex(['user_id'], 'dav_absence_uid_idx');
} else {
$table = $schema->getTable('dav_absence');
}
if ($table->getPrimaryKey() === null) {
$table->setPrimaryKey(['id'], 'dav_absence_id_idx');
}
return $schema;
}
}