123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480 |
- <?php
- /**
- * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
- * SPDX-License-Identifier: AGPL-3.0-or-later
- */
- 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');
- $table->addIndex(['lastmodified'], 'schedulobj_lastmodified_idx');
- }
- 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');
- // modified on 2024-6-21 to add performance improving indices on new instances
- $table->addIndex(['resourceid', 'type'], 'dav_shares_resourceid_type');
- $table->addIndex(['resourceid', 'access'], 'dav_shares_resourceid_access');
- }
- return $schema;
- }
- }
|