Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
<?php
/**
* @author Viktar Dubiniuk <dubiniuk@owncloud.com>
*
* @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 <http://www.gnu.org/licenses/>
*
*/

namespace OCA\FederatedFileSharing\Migrations;

Expand All @@ -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]);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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]));
}
Expand Down
41 changes: 41 additions & 0 deletions apps/files_sharing/appinfo/Migrations/Version20190426123324.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
/**
* @author Viktar Dubiniuk <dubiniuk@owncloud.com>
*
* @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 <http://www.gnu.org/licenses/>
*
*/

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]);
}
}
}
}
2 changes: 1 addition & 1 deletion apps/files_sharing/appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Turning the feature off removes shared files and folders on the server for all s
<licence>AGPL</licence>
<author>Michael Gapczynski, Bjoern Schiessle</author>
<default_enable/>
<version>0.11.0</version>
<version>0.12.0</version>
<types>
<filesystem/>
</types>
Expand Down