|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +/** |
| 6 | + * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors |
| 7 | + * SPDX-License-Identifier: AGPL-3.0-or-later |
| 8 | + */ |
| 9 | + |
| 10 | +namespace OCA\DAV\Migration; |
| 11 | + |
| 12 | +use Closure; |
| 13 | +use OCP\DB\ISchemaWrapper; |
| 14 | +use OCP\Migration\Attributes\ColumnType; |
| 15 | +use OCP\Migration\Attributes\ModifyColumn; |
| 16 | +use OCP\Migration\IOutput; |
| 17 | +use OCP\Migration\SimpleMigrationStep; |
| 18 | +use Override; |
| 19 | + |
| 20 | +#[ModifyColumn(table: 'calendarobjects', name: 'uid', type: ColumnType::STRING, description: 'Increase uid length to 512 characters')] |
| 21 | +#[ModifyColumn(table: 'calendar_reminders', name: 'uid', type: ColumnType::STRING, description: 'Increase uid length to 512 characters')] |
| 22 | +#[ModifyColumn(table: 'calendar_invitations', name: 'uid', type: ColumnType::STRING, description: 'Increase uid length to 512 characters')] |
| 23 | +class Version1036Date20251202000000 extends SimpleMigrationStep { |
| 24 | + /** |
| 25 | + * @param Closure(): ISchemaWrapper $schemaClosure |
| 26 | + */ |
| 27 | + #[Override] |
| 28 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
| 29 | + /** @var ISchemaWrapper $schema */ |
| 30 | + $schema = $schemaClosure(); |
| 31 | + $modified = false; |
| 32 | + |
| 33 | + $table = $schema->getTable('calendarobjects'); |
| 34 | + $column = $table->getColumn('uid'); |
| 35 | + if ($column->getLength() < 512) { |
| 36 | + $column->setLength(512); |
| 37 | + $modified = true; |
| 38 | + } |
| 39 | + |
| 40 | + $table = $schema->getTable('calendar_reminders'); |
| 41 | + $column = $table->getColumn('uid'); |
| 42 | + if ($column->getLength() < 512) { |
| 43 | + $column->setLength(512); |
| 44 | + $modified = true; |
| 45 | + } |
| 46 | + |
| 47 | + $table = $schema->getTable('calendar_invitations'); |
| 48 | + $column = $table->getColumn('uid'); |
| 49 | + if ($column->getLength() < 512) { |
| 50 | + $column->setLength(512); |
| 51 | + $modified = true; |
| 52 | + } |
| 53 | + |
| 54 | + return $modified ? $schema : null; |
| 55 | + } |
| 56 | +} |
0 commit comments