Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2020-12-03 19:39:56 +0300
committerJulius Härtl <jus@bitgrid.net>2020-12-14 13:10:59 +0300
commit3cf7041c94a8b02fd815a58798ff04918e4d5d63 (patch)
tree8bbd93660a138190e9b3de39954d30ff5732673e /apps/files_sharing/lib
parentff544a288092e32a85211250b20726239135a783 (diff)
Adjust default
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'apps/files_sharing/lib')
-rw-r--r--apps/files_sharing/lib/Migration/Version11300Date20201120141438.php46
1 files changed, 44 insertions, 2 deletions
diff --git a/apps/files_sharing/lib/Migration/Version11300Date20201120141438.php b/apps/files_sharing/lib/Migration/Version11300Date20201120141438.php
index 61833249828..dfc5bc68a07 100644
--- a/apps/files_sharing/lib/Migration/Version11300Date20201120141438.php
+++ b/apps/files_sharing/lib/Migration/Version11300Date20201120141438.php
@@ -2,16 +2,48 @@
declare(strict_types=1);
+/*
+ * @copyright Copyright (c) 2020 Julius Härtl <jus@bitgrid.net>
+ *
+ * @author Julius Härtl <jus@bitgrid.net>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
namespace OCA\Files_Sharing\Migration;
use Closure;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use OCP\DB\ISchemaWrapper;
+use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
class Version11300Date20201120141438 extends SimpleMigrationStep {
+
+ /** @var IDBConnection */
+ private $connection;
+
+ public function __construct(IDBConnection $connection) {
+ $this->connection = $connection;
+ }
+
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
@@ -35,9 +67,9 @@ class Version11300Date20201120141438 extends SimpleMigrationStep {
'length' => 512,
]);
$table->addColumn('remote_id', Types::STRING, [
- 'notnull' => true,
+ 'notnull' => false,
'length' => 255,
- 'default' => -1,
+ 'default' => '',
]);
$table->addColumn('share_token', Types::STRING, [
'notnull' => true,
@@ -79,11 +111,21 @@ class Version11300Date20201120141438 extends SimpleMigrationStep {
$table = $schema->getTable('share_external');
$remoteIdColumn = $table->getColumn('remote_id');
if ($remoteIdColumn && $remoteIdColumn->getType()->getName() !== Types::STRING) {
+ $remoteIdColumn->setNotnull(false);
$remoteIdColumn->setType(Type::getType(Types::STRING));
$remoteIdColumn->setOptions(['length' => 255]);
+ $remoteIdColumn->setDefault('');
}
}
return $schema;
}
+
+ public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
+ $qb = $this->connection->getQueryBuilder();
+ $qb->update('share_external')
+ ->set('remote_id', $qb->createNamedParameter(''))
+ ->where($qb->expr()->eq('remote_id', $qb->createNamedParameter('-1')));
+ $qb->execute();
+ }
}