|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +/** |
| 6 | + * @copyright Copyright (c) 2023 Your name <your@email.com> |
| 7 | + * |
| 8 | + * @author Your name <your@email.com> |
| 9 | + * |
| 10 | + * @license GNU AGPL version 3 or any later version |
| 11 | + * |
| 12 | + * This program is free software: you can redistribute it and/or modify |
| 13 | + * it under the terms of the GNU Affero General Public License as |
| 14 | + * published by the Free Software Foundation, either version 3 of the |
| 15 | + * License, or (at your option) any later version. |
| 16 | + * |
| 17 | + * This program is distributed in the hope that it will be useful, |
| 18 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | + * GNU Affero General Public License for more details. |
| 21 | + * |
| 22 | + * You should have received a copy of the GNU Affero General Public License |
| 23 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 24 | + * |
| 25 | + */ |
| 26 | + |
| 27 | +namespace OCA\DAV\Migration; |
| 28 | + |
| 29 | +use Closure; |
| 30 | +use OCP\DB\ISchemaWrapper; |
| 31 | +use OCP\Migration\IOutput; |
| 32 | +use OCP\Migration\SimpleMigrationStep; |
| 33 | + |
| 34 | +/** |
| 35 | + * Auto-generated migration step: Please modify to your needs! |
| 36 | + */ |
| 37 | +class Version1028Date20230702074342 extends SimpleMigrationStep { |
| 38 | + |
| 39 | + /** |
| 40 | + * @param IOutput $output |
| 41 | + * @param Closure(): ISchemaWrapper $schemaClosure |
| 42 | + * @param array $options |
| 43 | + */ |
| 44 | + public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void { |
| 45 | + } |
| 46 | + |
| 47 | + /** |
| 48 | + * @param IOutput $output |
| 49 | + * @param Closure(): ISchemaWrapper $schemaClosure |
| 50 | + * @param array $options |
| 51 | + * @return null|ISchemaWrapper |
| 52 | + */ |
| 53 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
| 54 | + /** @var ISchemaWrapper $schema */ |
| 55 | + $schema = $schemaClosure(); |
| 56 | + $propertiesTable = $schema->getTable('properties'); |
| 57 | + |
| 58 | + // Indexes can't be added on columns with such length, so we drop them here before recreating them |
| 59 | + $propertiesTable->dropIndex('properties_path_index'); |
| 60 | + $propertiesTable->dropIndex('properties_pathonly_index'); |
| 61 | + |
| 62 | + $propertyValueColumn = $propertiesTable->getColumn('propertypath'); |
| 63 | + $propertyValueColumn->setLength(4000); |
| 64 | + |
| 65 | + $propertiesTable->addIndex(['userid', 'propertypath'], 'properties_path_index_prefix', [], ['lengths' => [null, 64]]); |
| 66 | + $propertiesTable->addIndex(['propertypath'], 'properties_pathonly_index_prefix', [], ['lengths' => [null, 64]]); |
| 67 | + |
| 68 | + return $schema; |
| 69 | + } |
| 70 | + |
| 71 | + /** |
| 72 | + * @param IOutput $output |
| 73 | + * @param Closure(): ISchemaWrapper $schemaClosure |
| 74 | + * @param array $options |
| 75 | + */ |
| 76 | + public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void { |
| 77 | + } |
| 78 | +} |
0 commit comments