From 9c54467c94465d410c8ca50c69079a45da61aec2 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Wed, 23 Dec 2020 14:41:02 +0100 Subject: [PATCH 1/2] Adjust share_external table Add column "parent" if missing. Drop column "lastscan" if exists. Signed-off-by: Vincent Petry --- apps/files_sharing/appinfo/info.xml | 2 +- .../composer/composer/autoload_classmap.php | 1 + .../composer/composer/autoload_static.php | 1 + .../Version11300Date20201120141438.php | 9 +++ .../Version21000Date20201223143245.php | 63 +++++++++++++++++++ 5 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 apps/files_sharing/lib/Migration/Version21000Date20201223143245.php diff --git a/apps/files_sharing/appinfo/info.xml b/apps/files_sharing/appinfo/info.xml index 492b34859b94b..1aa5393ecb914 100644 --- a/apps/files_sharing/appinfo/info.xml +++ b/apps/files_sharing/appinfo/info.xml @@ -9,7 +9,7 @@ Turning the feature off removes shared files and folders on the server for all share recipients, and also on the sync clients and mobile apps. More information is available in the Nextcloud Documentation. - 1.12.1 + 1.12.2 agpl Michael Gapczynski Bjoern Schiessle diff --git a/apps/files_sharing/composer/composer/autoload_classmap.php b/apps/files_sharing/composer/composer/autoload_classmap.php index a29e3879e06e3..dfd6ae75e82fc 100644 --- a/apps/files_sharing/composer/composer/autoload_classmap.php +++ b/apps/files_sharing/composer/composer/autoload_classmap.php @@ -63,6 +63,7 @@ 'OCA\\Files_Sharing\\Migration\\SetAcceptedStatus' => $baseDir . '/../lib/Migration/SetAcceptedStatus.php', 'OCA\\Files_Sharing\\Migration\\SetPasswordColumn' => $baseDir . '/../lib/Migration/SetPasswordColumn.php', 'OCA\\Files_Sharing\\Migration\\Version11300Date20201120141438' => $baseDir . '/../lib/Migration/Version11300Date20201120141438.php', + 'OCA\\Files_Sharing\\Migration\\Version21000Date20201223143245' => $baseDir . '/../lib/Migration/Version21000Date20201223143245.php', 'OCA\\Files_Sharing\\MountProvider' => $baseDir . '/../lib/MountProvider.php', 'OCA\\Files_Sharing\\Notification\\Listener' => $baseDir . '/../lib/Notification/Listener.php', 'OCA\\Files_Sharing\\Notification\\Notifier' => $baseDir . '/../lib/Notification/Notifier.php', diff --git a/apps/files_sharing/composer/composer/autoload_static.php b/apps/files_sharing/composer/composer/autoload_static.php index 523f2bc194515..b433cb23663a2 100644 --- a/apps/files_sharing/composer/composer/autoload_static.php +++ b/apps/files_sharing/composer/composer/autoload_static.php @@ -78,6 +78,7 @@ class ComposerStaticInitFiles_Sharing 'OCA\\Files_Sharing\\Migration\\SetAcceptedStatus' => __DIR__ . '/..' . '/../lib/Migration/SetAcceptedStatus.php', 'OCA\\Files_Sharing\\Migration\\SetPasswordColumn' => __DIR__ . '/..' . '/../lib/Migration/SetPasswordColumn.php', 'OCA\\Files_Sharing\\Migration\\Version11300Date20201120141438' => __DIR__ . '/..' . '/../lib/Migration/Version11300Date20201120141438.php', + 'OCA\\Files_Sharing\\Migration\\Version21000Date20201223143245' => __DIR__ . '/..' . '/../lib/Migration/Version21000Date20201223143245.php', 'OCA\\Files_Sharing\\MountProvider' => __DIR__ . '/..' . '/../lib/MountProvider.php', 'OCA\\Files_Sharing\\Notification\\Listener' => __DIR__ . '/..' . '/../lib/Notification/Listener.php', 'OCA\\Files_Sharing\\Notification\\Notifier' => __DIR__ . '/..' . '/../lib/Notification/Notifier.php', diff --git a/apps/files_sharing/lib/Migration/Version11300Date20201120141438.php b/apps/files_sharing/lib/Migration/Version11300Date20201120141438.php index dfc5bc68a07d7..077c825c0a101 100644 --- a/apps/files_sharing/lib/Migration/Version11300Date20201120141438.php +++ b/apps/files_sharing/lib/Migration/Version11300Date20201120141438.php @@ -116,6 +116,15 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt $remoteIdColumn->setOptions(['length' => 255]); $remoteIdColumn->setDefault(''); } + if (!$table->hasColumn('parent')) { + $table->addColumn('parent', Types::BIGINT, [ + 'notnull' => false, + 'default' => -1, + ]); + } + if ($table->hasColumn('lastscan')) { + $table->dropColumn('lastscan'); + } } return $schema; diff --git a/apps/files_sharing/lib/Migration/Version21000Date20201223143245.php b/apps/files_sharing/lib/Migration/Version21000Date20201223143245.php new file mode 100644 index 0000000000000..3e9fda47c468a --- /dev/null +++ b/apps/files_sharing/lib/Migration/Version21000Date20201223143245.php @@ -0,0 +1,63 @@ + + * + * @author Vincent Petry + * + * @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 . + * + */ + + +namespace OCA\Files_Sharing\Migration; + +use Closure; +use Doctrine\DBAL\Types\Types; +use OCP\DB\ISchemaWrapper; +use OCP\Migration\IOutput; +use OCP\Migration\SimpleMigrationStep; + +class Version21000Date20201223143245 extends SimpleMigrationStep { + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { + /** @var ISchemaWrapper $schema */ + $schema = $schemaClosure(); + + if ($schema->hasTable('share_external')) { + $table = $schema->getTable('share_external'); + $changed = false; + if (!$table->hasColumn('parent')) { + $table->addColumn('parent', Types::BIGINT, [ + 'notnull' => false, + 'default' => -1, + ]); + $changed = true; + } + if ($table->hasColumn('lastscan')) { + $table->dropColumn('lastscan'); + $changed = true; + } + + if ($changed) { + return $schema; + } + } + + return null; + } +} From 9c7d733c0119f0b6e1053e646c2e63a7318e7cc3 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Wed, 23 Dec 2020 16:17:29 +0100 Subject: [PATCH 2/2] Also add missing oc_share_external.share_type column Signed-off-by: Vincent Petry --- .../lib/Migration/Version11300Date20201120141438.php | 6 ++++++ .../lib/Migration/Version21000Date20201223143245.php | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/apps/files_sharing/lib/Migration/Version11300Date20201120141438.php b/apps/files_sharing/lib/Migration/Version11300Date20201120141438.php index 077c825c0a101..ff616022be49f 100644 --- a/apps/files_sharing/lib/Migration/Version11300Date20201120141438.php +++ b/apps/files_sharing/lib/Migration/Version11300Date20201120141438.php @@ -122,6 +122,12 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt 'default' => -1, ]); } + if (!$table->hasColumn('share_type')) { + $table->addColumn('share_type', Types::INTEGER, [ + 'notnull' => false, + 'length' => 4, + ]); + } if ($table->hasColumn('lastscan')) { $table->dropColumn('lastscan'); } diff --git a/apps/files_sharing/lib/Migration/Version21000Date20201223143245.php b/apps/files_sharing/lib/Migration/Version21000Date20201223143245.php index 3e9fda47c468a..5dfdb09f1ecb7 100644 --- a/apps/files_sharing/lib/Migration/Version21000Date20201223143245.php +++ b/apps/files_sharing/lib/Migration/Version21000Date20201223143245.php @@ -48,6 +48,13 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt ]); $changed = true; } + if (!$table->hasColumn('share_type')) { + $table->addColumn('share_type', Types::INTEGER, [ + 'notnull' => false, + 'length' => 4, + ]); + $changed = true; + } if ($table->hasColumn('lastscan')) { $table->dropColumn('lastscan'); $changed = true;