Skip to content

Commit 2dbf407

Browse files
authored
Merge pull request #24963 from nextcloud/backport/24829/stable20
[stable20] Add migration for oc_share_external columns
2 parents 2fa3f24 + 9c7d733 commit 2dbf407

File tree

5 files changed

+88
-1
lines changed

5 files changed

+88
-1
lines changed

apps/files_sharing/appinfo/info.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
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.
1010

1111
</description>
12-
<version>1.12.1</version>
12+
<version>1.12.2</version>
1313
<licence>agpl</licence>
1414
<author>Michael Gapczynski</author>
1515
<author>Bjoern Schiessle</author>

apps/files_sharing/composer/composer/autoload_classmap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
'OCA\\Files_Sharing\\Migration\\SetAcceptedStatus' => $baseDir . '/../lib/Migration/SetAcceptedStatus.php',
6464
'OCA\\Files_Sharing\\Migration\\SetPasswordColumn' => $baseDir . '/../lib/Migration/SetPasswordColumn.php',
6565
'OCA\\Files_Sharing\\Migration\\Version11300Date20201120141438' => $baseDir . '/../lib/Migration/Version11300Date20201120141438.php',
66+
'OCA\\Files_Sharing\\Migration\\Version21000Date20201223143245' => $baseDir . '/../lib/Migration/Version21000Date20201223143245.php',
6667
'OCA\\Files_Sharing\\MountProvider' => $baseDir . '/../lib/MountProvider.php',
6768
'OCA\\Files_Sharing\\Notification\\Listener' => $baseDir . '/../lib/Notification/Listener.php',
6869
'OCA\\Files_Sharing\\Notification\\Notifier' => $baseDir . '/../lib/Notification/Notifier.php',

apps/files_sharing/composer/composer/autoload_static.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ class ComposerStaticInitFiles_Sharing
7878
'OCA\\Files_Sharing\\Migration\\SetAcceptedStatus' => __DIR__ . '/..' . '/../lib/Migration/SetAcceptedStatus.php',
7979
'OCA\\Files_Sharing\\Migration\\SetPasswordColumn' => __DIR__ . '/..' . '/../lib/Migration/SetPasswordColumn.php',
8080
'OCA\\Files_Sharing\\Migration\\Version11300Date20201120141438' => __DIR__ . '/..' . '/../lib/Migration/Version11300Date20201120141438.php',
81+
'OCA\\Files_Sharing\\Migration\\Version21000Date20201223143245' => __DIR__ . '/..' . '/../lib/Migration/Version21000Date20201223143245.php',
8182
'OCA\\Files_Sharing\\MountProvider' => __DIR__ . '/..' . '/../lib/MountProvider.php',
8283
'OCA\\Files_Sharing\\Notification\\Listener' => __DIR__ . '/..' . '/../lib/Notification/Listener.php',
8384
'OCA\\Files_Sharing\\Notification\\Notifier' => __DIR__ . '/..' . '/../lib/Notification/Notifier.php',

apps/files_sharing/lib/Migration/Version11300Date20201120141438.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,21 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
116116
$remoteIdColumn->setOptions(['length' => 255]);
117117
$remoteIdColumn->setDefault('');
118118
}
119+
if (!$table->hasColumn('parent')) {
120+
$table->addColumn('parent', Types::BIGINT, [
121+
'notnull' => false,
122+
'default' => -1,
123+
]);
124+
}
125+
if (!$table->hasColumn('share_type')) {
126+
$table->addColumn('share_type', Types::INTEGER, [
127+
'notnull' => false,
128+
'length' => 4,
129+
]);
130+
}
131+
if ($table->hasColumn('lastscan')) {
132+
$table->dropColumn('lastscan');
133+
}
119134
}
120135

121136
return $schema;
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* @copyright Copyright (c) 2020 Vincent Petry <vincent@nextcloud.com>
7+
*
8+
* @author Vincent Petry <vincent@nextcloud.com>
9+
*
10+
* @license GNU AGPL version 3 or any later version
11+
*
12+
* This program is free software: you can redistribute it and/or modify
13+
* it under the terms of the GNU Affero General Public License as
14+
* published by the Free Software Foundation, either version 3 of the
15+
* License, or (at your option) any later version.
16+
*
17+
* This program is distributed in the hope that it will be useful,
18+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+
* GNU Affero General Public License for more details.
21+
*
22+
* You should have received a copy of the GNU Affero General Public License
23+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
24+
*
25+
*/
26+
27+
28+
namespace OCA\Files_Sharing\Migration;
29+
30+
use Closure;
31+
use Doctrine\DBAL\Types\Types;
32+
use OCP\DB\ISchemaWrapper;
33+
use OCP\Migration\IOutput;
34+
use OCP\Migration\SimpleMigrationStep;
35+
36+
class Version21000Date20201223143245 extends SimpleMigrationStep {
37+
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
38+
/** @var ISchemaWrapper $schema */
39+
$schema = $schemaClosure();
40+
41+
if ($schema->hasTable('share_external')) {
42+
$table = $schema->getTable('share_external');
43+
$changed = false;
44+
if (!$table->hasColumn('parent')) {
45+
$table->addColumn('parent', Types::BIGINT, [
46+
'notnull' => false,
47+
'default' => -1,
48+
]);
49+
$changed = true;
50+
}
51+
if (!$table->hasColumn('share_type')) {
52+
$table->addColumn('share_type', Types::INTEGER, [
53+
'notnull' => false,
54+
'length' => 4,
55+
]);
56+
$changed = true;
57+
}
58+
if ($table->hasColumn('lastscan')) {
59+
$table->dropColumn('lastscan');
60+
$changed = true;
61+
}
62+
63+
if ($changed) {
64+
return $schema;
65+
}
66+
}
67+
68+
return null;
69+
}
70+
}

0 commit comments

Comments
 (0)