aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/lib/Migration
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_sharing/lib/Migration')
-rw-r--r--apps/files_sharing/lib/Migration/OwncloudGuestShareType.php48
-rw-r--r--apps/files_sharing/lib/Migration/SetAcceptedStatus.php56
-rw-r--r--apps/files_sharing/lib/Migration/SetPasswordColumn.php45
-rw-r--r--apps/files_sharing/lib/Migration/Version11300Date20201120141438.php124
-rw-r--r--apps/files_sharing/lib/Migration/Version21000Date20201223143245.php51
-rw-r--r--apps/files_sharing/lib/Migration/Version22000Date20210216084241.php37
-rw-r--r--apps/files_sharing/lib/Migration/Version24000Date20220208195521.php34
-rw-r--r--apps/files_sharing/lib/Migration/Version24000Date20220404142216.php39
-rw-r--r--apps/files_sharing/lib/Migration/Version31000Date20240821142813.php43
9 files changed, 406 insertions, 71 deletions
diff --git a/apps/files_sharing/lib/Migration/OwncloudGuestShareType.php b/apps/files_sharing/lib/Migration/OwncloudGuestShareType.php
index 07f739fb702..3718306e380 100644
--- a/apps/files_sharing/lib/Migration/OwncloudGuestShareType.php
+++ b/apps/files_sharing/lib/Migration/OwncloudGuestShareType.php
@@ -1,33 +1,16 @@
<?php
+
/**
- * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com>
- *
- * @author Joas Schilling <coding@schilljs.com>
- *
- * @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/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
-
namespace OCA\Files_Sharing\Migration;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;
-use OCP\Share;
+use OCP\Share\IShare;
/**
* Class OwncloudGuestShareType
@@ -36,16 +19,10 @@ use OCP\Share;
*/
class OwncloudGuestShareType implements IRepairStep {
- /** @var IDBConnection */
- private $connection;
-
- /** @var IConfig */
- private $config;
-
-
- public function __construct(IDBConnection $connection, IConfig $config) {
- $this->connection = $connection;
- $this->config = $config;
+ public function __construct(
+ private IDBConnection $connection,
+ private IConfig $config,
+ ) {
}
/**
@@ -68,15 +45,14 @@ class OwncloudGuestShareType implements IRepairStep {
$query = $this->connection->getQueryBuilder();
$query->update('share')
- ->set('share_type', $query->createNamedParameter(Share::SHARE_TYPE_GUEST))
- ->where($query->expr()->eq('share_type', $query->createNamedParameter(Share::SHARE_TYPE_EMAIL)));
+ ->set('share_type', $query->createNamedParameter(IShare::TYPE_GUEST))
+ ->where($query->expr()->eq('share_type', $query->createNamedParameter(IShare::TYPE_EMAIL)));
$query->execute();
}
protected function shouldRun() {
$appVersion = $this->config->getAppValue('files_sharing', 'installed_version', '0.0.0');
- return in_array($appVersion, ['0.10.0']) ||
- $this->config->getAppValue('core', 'vendor', '') === 'owncloud';
+ return $appVersion === '0.10.0'
+ || $this->config->getAppValue('core', 'vendor', '') === 'owncloud';
}
-
}
diff --git a/apps/files_sharing/lib/Migration/SetAcceptedStatus.php b/apps/files_sharing/lib/Migration/SetAcceptedStatus.php
new file mode 100644
index 00000000000..4da6aad4b33
--- /dev/null
+++ b/apps/files_sharing/lib/Migration/SetAcceptedStatus.php
@@ -0,0 +1,56 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCA\Files_Sharing\Migration;
+
+use OCP\DB\QueryBuilder\IQueryBuilder;
+use OCP\IConfig;
+use OCP\IDBConnection;
+use OCP\Migration\IOutput;
+use OCP\Migration\IRepairStep;
+use OCP\Share\IShare;
+
+class SetAcceptedStatus implements IRepairStep {
+
+ public function __construct(
+ private IDBConnection $connection,
+ private IConfig $config,
+ ) {
+ }
+
+ /**
+ * Returns the step's name
+ *
+ * @return string
+ * @since 9.1.0
+ */
+ public function getName(): string {
+ return 'Set existing shares as accepted';
+ }
+
+ /**
+ * @param IOutput $output
+ */
+ public function run(IOutput $output): void {
+ if (!$this->shouldRun()) {
+ return;
+ }
+
+ $query = $this->connection->getQueryBuilder();
+ $query
+ ->update('share')
+ ->set('accepted', $query->createNamedParameter(IShare::STATUS_ACCEPTED))
+ ->where($query->expr()->in('share_type', $query->createNamedParameter([IShare::TYPE_USER, IShare::TYPE_GROUP, IShare::TYPE_USERGROUP], IQueryBuilder::PARAM_INT_ARRAY)));
+ $query->executeStatement();
+ }
+
+ protected function shouldRun() {
+ $appVersion = $this->config->getAppValue('files_sharing', 'installed_version', '0.0.0');
+ return version_compare($appVersion, '1.10.1', '<');
+ }
+}
diff --git a/apps/files_sharing/lib/Migration/SetPasswordColumn.php b/apps/files_sharing/lib/Migration/SetPasswordColumn.php
index e8631485f88..f60af2817d4 100644
--- a/apps/files_sharing/lib/Migration/SetPasswordColumn.php
+++ b/apps/files_sharing/lib/Migration/SetPasswordColumn.php
@@ -1,33 +1,16 @@
<?php
+
/**
- * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com>
- *
- * @author Joas Schilling <coding@schilljs.com>
- *
- * @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/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
-
namespace OCA\Files_Sharing\Migration;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;
-use OCP\Share;
+use OCP\Share\IShare;
/**
* Class SetPasswordColumn
@@ -36,16 +19,10 @@ use OCP\Share;
*/
class SetPasswordColumn implements IRepairStep {
- /** @var IDBConnection */
- private $connection;
-
- /** @var IConfig */
- private $config;
-
-
- public function __construct(IDBConnection $connection, IConfig $config) {
- $this->connection = $connection;
- $this->config = $config;
+ public function __construct(
+ private IDBConnection $connection,
+ private IConfig $config,
+ ) {
}
/**
@@ -70,7 +47,7 @@ class SetPasswordColumn implements IRepairStep {
$query
->update('share')
->set('password', 'share_with')
- ->where($query->expr()->eq('share_type', $query->createNamedParameter(Share::SHARE_TYPE_LINK)))
+ ->where($query->expr()->eq('share_type', $query->createNamedParameter(IShare::TYPE_LINK)))
->andWhere($query->expr()->isNotNull('share_with'));
$result = $query->execute();
@@ -83,15 +60,13 @@ class SetPasswordColumn implements IRepairStep {
$clearQuery
->update('share')
->set('share_with', $clearQuery->createNamedParameter(null))
- ->where($clearQuery->expr()->eq('share_type', $clearQuery->createNamedParameter(Share::SHARE_TYPE_LINK)));
+ ->where($clearQuery->expr()->eq('share_type', $clearQuery->createNamedParameter(IShare::TYPE_LINK)));
$clearQuery->execute();
-
}
protected function shouldRun() {
$appVersion = $this->config->getAppValue('files_sharing', 'installed_version', '0.0.0');
return version_compare($appVersion, '1.4.0', '<');
}
-
}
diff --git a/apps/files_sharing/lib/Migration/Version11300Date20201120141438.php b/apps/files_sharing/lib/Migration/Version11300Date20201120141438.php
new file mode 100644
index 00000000000..c9fe840d422
--- /dev/null
+++ b/apps/files_sharing/lib/Migration/Version11300Date20201120141438.php
@@ -0,0 +1,124 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCA\Files_Sharing\Migration;
+
+use Closure;
+use Doctrine\DBAL\Types\Type;
+use OCP\DB\ISchemaWrapper;
+use OCP\DB\Types;
+use OCP\IDBConnection;
+use OCP\Migration\IOutput;
+use OCP\Migration\SimpleMigrationStep;
+
+class Version11300Date20201120141438 extends SimpleMigrationStep {
+
+ public function __construct(
+ private IDBConnection $connection,
+ ) {
+ }
+
+ public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
+ /** @var ISchemaWrapper $schema */
+ $schema = $schemaClosure();
+
+ if (!$schema->hasTable('share_external')) {
+ $table = $schema->createTable('share_external');
+ $table->addColumn('id', Types::BIGINT, [
+ 'autoincrement' => true,
+ 'notnull' => true,
+ ]);
+ $table->addColumn('parent', Types::BIGINT, [
+ 'notnull' => false,
+ 'default' => -1,
+ ]);
+ $table->addColumn('share_type', Types::INTEGER, [
+ 'notnull' => false,
+ 'length' => 4,
+ ]);
+ $table->addColumn('remote', Types::STRING, [
+ 'notnull' => true,
+ 'length' => 512,
+ ]);
+ $table->addColumn('remote_id', Types::STRING, [
+ 'notnull' => false,
+ 'length' => 255,
+ 'default' => '',
+ ]);
+ $table->addColumn('share_token', Types::STRING, [
+ 'notnull' => true,
+ 'length' => 64,
+ ]);
+ $table->addColumn('password', Types::STRING, [
+ 'notnull' => false,
+ 'length' => 64,
+ ]);
+ $table->addColumn('name', Types::STRING, [
+ 'notnull' => true,
+ 'length' => 64,
+ ]);
+ $table->addColumn('owner', Types::STRING, [
+ 'notnull' => true,
+ 'length' => 64,
+ ]);
+ $table->addColumn('user', Types::STRING, [
+ 'notnull' => true,
+ 'length' => 64,
+ ]);
+ $table->addColumn('mountpoint', Types::STRING, [
+ 'notnull' => true,
+ 'length' => 4000,
+ ]);
+ $table->addColumn('mountpoint_hash', Types::STRING, [
+ 'notnull' => true,
+ 'length' => 32,
+ ]);
+ $table->addColumn('accepted', Types::INTEGER, [
+ 'notnull' => true,
+ 'length' => 4,
+ 'default' => 0,
+ ]);
+ $table->setPrimaryKey(['id']);
+ $table->addUniqueIndex(['user', 'mountpoint_hash'], 'sh_external_mp');
+ } else {
+ $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('');
+ }
+ if (!$table->hasColumn('parent')) {
+ $table->addColumn('parent', Types::BIGINT, [
+ 'notnull' => false,
+ 'default' => -1,
+ ]);
+ }
+ if (!$table->hasColumn('share_type')) {
+ $table->addColumn('share_type', Types::INTEGER, [
+ 'notnull' => false,
+ 'length' => 4,
+ ]);
+ }
+ if ($table->hasColumn('lastscan')) {
+ $table->dropColumn('lastscan');
+ }
+ }
+
+ 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();
+ }
+}
diff --git a/apps/files_sharing/lib/Migration/Version21000Date20201223143245.php b/apps/files_sharing/lib/Migration/Version21000Date20201223143245.php
new file mode 100644
index 00000000000..9bd07a19802
--- /dev/null
+++ b/apps/files_sharing/lib/Migration/Version21000Date20201223143245.php
@@ -0,0 +1,51 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCA\Files_Sharing\Migration;
+
+use Closure;
+use OCP\DB\ISchemaWrapper;
+use OCP\DB\Types;
+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('share_type')) {
+ $table->addColumn('share_type', Types::INTEGER, [
+ 'notnull' => false,
+ 'length' => 4,
+ ]);
+ $changed = true;
+ }
+ if ($table->hasColumn('lastscan')) {
+ $table->dropColumn('lastscan');
+ $changed = true;
+ }
+
+ if ($changed) {
+ return $schema;
+ }
+ }
+
+ return null;
+ }
+}
diff --git a/apps/files_sharing/lib/Migration/Version22000Date20210216084241.php b/apps/files_sharing/lib/Migration/Version22000Date20210216084241.php
new file mode 100644
index 00000000000..e82fb4a72d5
--- /dev/null
+++ b/apps/files_sharing/lib/Migration/Version22000Date20210216084241.php
@@ -0,0 +1,37 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCA\Files_Sharing\Migration;
+
+use Closure;
+use OCP\DB\ISchemaWrapper;
+use OCP\Migration\IOutput;
+use OCP\Migration\SimpleMigrationStep;
+
+/**
+ * Auto-generated migration step: Please modify to your needs!
+ */
+class Version22000Date20210216084241 extends SimpleMigrationStep {
+ /**
+ * @param IOutput $output
+ * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
+ * @param array $options
+ * @return null|ISchemaWrapper
+ */
+ public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
+ /** @var ISchemaWrapper $schema */
+ $schema = $schemaClosure();
+
+ $table = $schema->getTable('share_external');
+ if ($table->hasIndex('sh_external_user')) {
+ $table->dropIndex('sh_external_user');
+ }
+
+ return $schema;
+ }
+}
diff --git a/apps/files_sharing/lib/Migration/Version24000Date20220208195521.php b/apps/files_sharing/lib/Migration/Version24000Date20220208195521.php
new file mode 100644
index 00000000000..75da1de1d83
--- /dev/null
+++ b/apps/files_sharing/lib/Migration/Version24000Date20220208195521.php
@@ -0,0 +1,34 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCA\Files_Sharing\Migration;
+
+use Closure;
+use OCP\DB\ISchemaWrapper;
+use OCP\DB\Types;
+use OCP\Migration\IOutput;
+use OCP\Migration\SimpleMigrationStep;
+
+class Version24000Date20220208195521 extends SimpleMigrationStep {
+
+ /**
+ * @param IOutput $output
+ * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
+ * @param array $options
+ * @return null|ISchemaWrapper
+ */
+ public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
+ $schema = $schemaClosure();
+ $table = $schema->getTable('share');
+ $table->addColumn('password_expiration_time', Types::DATETIME, [
+ 'notnull' => false,
+ ]);
+ return $schema;
+ }
+
+}
diff --git a/apps/files_sharing/lib/Migration/Version24000Date20220404142216.php b/apps/files_sharing/lib/Migration/Version24000Date20220404142216.php
new file mode 100644
index 00000000000..03985bd50c7
--- /dev/null
+++ b/apps/files_sharing/lib/Migration/Version24000Date20220404142216.php
@@ -0,0 +1,39 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace OCA\Files_Sharing\Migration;
+
+use Closure;
+use OCP\DB\ISchemaWrapper;
+use OCP\Migration\IOutput;
+use OCP\Migration\SimpleMigrationStep;
+
+/**
+ * Auto-generated migration step: Please modify to your needs!
+ */
+class Version24000Date20220404142216 extends SimpleMigrationStep {
+ /**
+ * @param IOutput $output
+ * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
+ * @param array $options
+ * @return null|ISchemaWrapper
+ */
+ public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
+ /** @var ISchemaWrapper $schema */
+ $schema = $schemaClosure();
+
+ $table = $schema->getTable('share_external');
+ $column = $table->getColumn('name');
+ if ($column->getLength() < 4000) {
+ $column->setLength(4000);
+ return $schema;
+ }
+ return null;
+ }
+}
diff --git a/apps/files_sharing/lib/Migration/Version31000Date20240821142813.php b/apps/files_sharing/lib/Migration/Version31000Date20240821142813.php
new file mode 100644
index 00000000000..71b2c1817e6
--- /dev/null
+++ b/apps/files_sharing/lib/Migration/Version31000Date20240821142813.php
@@ -0,0 +1,43 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace OCA\Files_Sharing\Migration;
+
+use Closure;
+use OCP\DB\ISchemaWrapper;
+use OCP\DB\Types;
+use OCP\Migration\Attributes\AddColumn;
+use OCP\Migration\Attributes\ColumnType;
+use OCP\Migration\IOutput;
+use OCP\Migration\SimpleMigrationStep;
+
+#[AddColumn(table: 'share', name: 'reminder_sent', type: ColumnType::BOOLEAN)]
+class Version31000Date20240821142813 extends SimpleMigrationStep {
+
+ /**
+ * @param IOutput $output
+ * @param Closure(): ISchemaWrapper $schemaClosure
+ * @param array $options
+ * @return null|ISchemaWrapper
+ */
+ public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
+ $schema = $schemaClosure();
+ $table = $schema->getTable('share');
+ if ($table->hasColumn('reminder_sent')) {
+ return null;
+ }
+
+ $table->addColumn('reminder_sent', Types::BOOLEAN, [
+ 'notnull' => false,
+ 'default' => false,
+ ]);
+ return $schema;
+ }
+
+}