2018-06-28 14:07:33 +03:00
|
|
|
<?php
|
2019-12-03 21:57:53 +03:00
|
|
|
|
2018-06-28 14:07:33 +03:00
|
|
|
declare(strict_types=1);
|
2019-12-03 21:57:53 +03:00
|
|
|
|
2018-06-28 14:07:33 +03:00
|
|
|
/**
|
|
|
|
* @copyright 2018 Georg Ehrke <oc.list@georgehrke.com>
|
|
|
|
*
|
2020-08-24 15:54:25 +03:00
|
|
|
* @author Daniel Kesselberg <mail@danielkesselberg.de>
|
2018-06-28 14:07:33 +03:00
|
|
|
* @author Georg Ehrke <oc.list@georgehrke.com>
|
2019-12-03 21:57:53 +03:00
|
|
|
* @author Joas Schilling <coding@schilljs.com>
|
|
|
|
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
2018-06-28 14:07:33 +03:00
|
|
|
*
|
|
|
|
* @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
|
2019-12-03 21:57:53 +03:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2018-06-28 14:07:33 +03:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace OCA\DAV\Migration;
|
|
|
|
|
2020-06-30 23:12:06 +03:00
|
|
|
use Doctrine\DBAL\Types\Types;
|
2018-06-28 14:07:33 +03:00
|
|
|
use OCP\DB\ISchemaWrapper;
|
|
|
|
use OCP\Migration\IOutput;
|
2019-11-22 22:52:10 +03:00
|
|
|
use OCP\Migration\SimpleMigrationStep;
|
2018-06-28 14:07:33 +03:00
|
|
|
|
|
|
|
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');
|
2020-06-30 23:12:06 +03:00
|
|
|
$calendarChangesTable->addColumn('calendartype', Types::INTEGER, [
|
2018-06-28 14:07:33 +03:00
|
|
|
'notnull' => true,
|
|
|
|
'default' => 0,
|
|
|
|
]);
|
|
|
|
|
|
|
|
if ($calendarChangesTable->hasIndex('calendarid_synctoken')) {
|
|
|
|
$calendarChangesTable->dropIndex('calendarid_synctoken');
|
|
|
|
}
|
2018-11-14 11:39:14 +03:00
|
|
|
$calendarChangesTable->addIndex(['calendarid', 'calendartype', 'synctoken'], 'calid_type_synctoken');
|
2018-06-28 14:07:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($schema->hasTable('calendarobjects')) {
|
|
|
|
$calendarObjectsTable = $schema->getTable('calendarobjects');
|
2020-06-30 23:12:06 +03:00
|
|
|
$calendarObjectsTable->addColumn('calendartype', Types::INTEGER, [
|
2018-06-28 14:07:33 +03:00
|
|
|
'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');
|
2020-06-30 23:12:06 +03:00
|
|
|
$calendarObjectsPropsTable->addColumn('calendartype', Types::INTEGER, [
|
2018-06-28 14:07:33 +03:00
|
|
|
'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');
|
2020-03-03 15:12:58 +03:00
|
|
|
$calendarObjectsPropsTable->addIndex(['calendarid', 'calendartype'], 'calendarobject_calid_index');
|
2018-06-28 14:07:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($schema->hasTable('calendarsubscriptions')) {
|
|
|
|
$calendarSubscriptionsTable = $schema->getTable('calendarsubscriptions');
|
|
|
|
$calendarSubscriptionsTable->addColumn('synctoken', 'integer', [
|
|
|
|
'notnull' => true,
|
|
|
|
'default' => 1,
|
|
|
|
'length' => 10,
|
|
|
|
'unsigned' => true,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $schema;
|
|
|
|
}
|
|
|
|
}
|