|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +/** |
| 6 | + * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors |
| 7 | + * SPDX-License-Identifier: AGPL-3.0-or-later |
| 8 | + */ |
| 9 | + |
| 10 | +namespace OCA\Richdocuments\Migration; |
| 11 | + |
| 12 | +use Closure; |
| 13 | +use OCP\DB\ISchemaWrapper; |
| 14 | +use OCP\Migration\IOutput; |
| 15 | +use OCP\Migration\SimpleMigrationStep; |
| 16 | +use Override; |
| 17 | + |
| 18 | +/** |
| 19 | + * Widen uid columns from varchar(64) to varchar(255) to support federated cloud IDs |
| 20 | + */ |
| 21 | +class Version10100Date20260226000000 extends SimpleMigrationStep { |
| 22 | + #[Override] |
| 23 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
| 24 | + /** @var ISchemaWrapper $schema */ |
| 25 | + $schema = $schemaClosure(); |
| 26 | + $changed = false; |
| 27 | + |
| 28 | + if ($schema->hasTable('richdocuments_wopi')) { |
| 29 | + $table = $schema->getTable('richdocuments_wopi'); |
| 30 | + foreach (['owner_uid', 'editor_uid'] as $columnName) { |
| 31 | + if ($table->hasColumn($columnName) && $table->getColumn($columnName)->getLength() < 255) { |
| 32 | + $table->changeColumn($columnName, [ |
| 33 | + 'length' => 255, |
| 34 | + ]); |
| 35 | + $changed = true; |
| 36 | + } |
| 37 | + } |
| 38 | + } |
| 39 | + |
| 40 | + if ($schema->hasTable('richdocuments_direct')) { |
| 41 | + $table = $schema->getTable('richdocuments_direct'); |
| 42 | + if ($table->hasColumn('uid') && $table->getColumn('uid')->getLength() < 255) { |
| 43 | + $table->changeColumn('uid', [ |
| 44 | + 'length' => 255, |
| 45 | + ]); |
| 46 | + $changed = true; |
| 47 | + } |
| 48 | + } |
| 49 | + |
| 50 | + if ($schema->hasTable('richdocuments_assets')) { |
| 51 | + $table = $schema->getTable('richdocuments_assets'); |
| 52 | + if ($table->hasColumn('uid') && $table->getColumn('uid')->getLength() < 255) { |
| 53 | + $table->changeColumn('uid', [ |
| 54 | + 'length' => 255, |
| 55 | + ]); |
| 56 | + $changed = true; |
| 57 | + } |
| 58 | + } |
| 59 | + |
| 60 | + return $changed ? $schema : null; |
| 61 | + } |
| 62 | +} |
0 commit comments