From 2ba3d0892042e9f6f5b3046a49bf4bb8e2fa64be Mon Sep 17 00:00:00 2001 From: Victor Dubiniuk Date: Fri, 26 Apr 2019 12:45:34 +0300 Subject: [PATCH] Move share_external migration into the sharing app --- .../Migrations/Version20190410160725.php | 28 +++++++++---- .../Migrations/Version20190410160725Test.php | 12 ++---- .../Migrations/Version20190426123324.php | 41 +++++++++++++++++++ apps/files_sharing/appinfo/info.xml | 2 +- 4 files changed, 65 insertions(+), 18 deletions(-) create mode 100644 apps/files_sharing/appinfo/Migrations/Version20190426123324.php diff --git a/apps/federatedfilesharing/appinfo/Migrations/Version20190410160725.php b/apps/federatedfilesharing/appinfo/Migrations/Version20190410160725.php index e3423044fb57..aebdc784fd67 100644 --- a/apps/federatedfilesharing/appinfo/Migrations/Version20190410160725.php +++ b/apps/federatedfilesharing/appinfo/Migrations/Version20190410160725.php @@ -1,4 +1,23 @@ + * + * @copyright Copyright (c) 2019, ownCloud GmbH + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * 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, version 3, + * along with this program. If not, see + * + */ namespace OCA\FederatedFileSharing\Migrations; @@ -19,14 +38,5 @@ public function changeSchema(Schema $schema, array $options) { $remoteIdColumn->setOptions(['length' => 255]); } } - - if ($schema->hasTable("${prefix}share_external")) { - $table = $schema->getTable("{$prefix}share_external"); - $remoteIdColumn = $table->getColumn('remote_id'); - if ($remoteIdColumn && $remoteIdColumn->getType()->getName() !== Type::STRING) { - $remoteIdColumn->setType(Type::getType(Type::STRING)); - $remoteIdColumn->setOptions(['length' => 255]); - } - } } } diff --git a/apps/federatedfilesharing/tests/appinfo/Migrations/Version20190410160725Test.php b/apps/federatedfilesharing/tests/appinfo/Migrations/Version20190410160725Test.php index 871d4fd9c401..04dbb698aada 100644 --- a/apps/federatedfilesharing/tests/appinfo/Migrations/Version20190410160725Test.php +++ b/apps/federatedfilesharing/tests/appinfo/Migrations/Version20190410160725Test.php @@ -16,14 +16,10 @@ public function testExecute() { $migration = new Version20190410160725(); $table = $this->createMock(Table::class); $schema = $this->createMock(Schema::class); - $schema->method('hasTable')->withConsecutive( - ['pr_federated_reshares'], - ['pr_share_external'] - )->willReturn(true); - $schema->method('getTable')->withConsecutive( - ['pr_federated_reshares'], - ['pr_share_external'] - )->willReturn($table); + $schema->method('hasTable')->with('pr_federated_reshares') + ->willReturn(true); + $schema->method('getTable')->with('pr_federated_reshares') + ->willReturn($table); $this->assertNull($migration->changeSchema($schema, ['tablePrefix' => $tablePrefix])); } diff --git a/apps/files_sharing/appinfo/Migrations/Version20190426123324.php b/apps/files_sharing/appinfo/Migrations/Version20190426123324.php new file mode 100644 index 000000000000..1ef23263ad94 --- /dev/null +++ b/apps/files_sharing/appinfo/Migrations/Version20190426123324.php @@ -0,0 +1,41 @@ + + * + * @copyright Copyright (c) 2019, ownCloud GmbH + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * 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, version 3, + * along with this program. If not, see + * + */ + +namespace OCA\Files_Sharing\Migrations; + +use Doctrine\DBAL\Schema\Schema; +use Doctrine\DBAL\Types\Type; +use OCP\Migration\ISchemaMigration; + +/** Updates remote_id to be string if required */ +class Version20190426123324 implements ISchemaMigration { + public function changeSchema(Schema $schema, array $options) { + $prefix = $options['tablePrefix']; + if ($schema->hasTable("${prefix}share_external")) { + $table = $schema->getTable("{$prefix}share_external"); + $remoteIdColumn = $table->getColumn('remote_id'); + if ($remoteIdColumn && $remoteIdColumn->getType()->getName() !== Type::STRING) { + $remoteIdColumn->setType(Type::getType(Type::STRING)); + $remoteIdColumn->setOptions(['length' => 255]); + } + } + } +} diff --git a/apps/files_sharing/appinfo/info.xml b/apps/files_sharing/appinfo/info.xml index 26e1574a3214..6c6ee9cdb681 100644 --- a/apps/files_sharing/appinfo/info.xml +++ b/apps/files_sharing/appinfo/info.xml @@ -10,7 +10,7 @@ Turning the feature off removes shared files and folders on the server for all s AGPL Michael Gapczynski, Bjoern Schiessle - 0.11.0 + 0.12.0