aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/DB/SchemaWrapper.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/DB/SchemaWrapper.php')
-rw-r--r--lib/private/DB/SchemaWrapper.php36
1 files changed, 13 insertions, 23 deletions
diff --git a/lib/private/DB/SchemaWrapper.php b/lib/private/DB/SchemaWrapper.php
index 31b74014a98..0d5b2040513 100644
--- a/lib/private/DB/SchemaWrapper.php
+++ b/lib/private/DB/SchemaWrapper.php
@@ -1,25 +1,8 @@
<?php
+
/**
- * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com>
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @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 OC\DB;
@@ -38,9 +21,13 @@ class SchemaWrapper implements ISchemaWrapper {
/** @var array */
protected $tablesToDelete = [];
- public function __construct(Connection $connection) {
+ public function __construct(Connection $connection, ?Schema $schema = null) {
$this->connection = $connection;
- $this->schema = $this->connection->createSchema();
+ if ($schema) {
+ $this->schema = $schema;
+ } else {
+ $this->schema = $this->connection->createSchema();
+ }
}
public function getWrappedSchema() {
@@ -50,6 +37,9 @@ class SchemaWrapper implements ISchemaWrapper {
public function performDropTableCalls() {
foreach ($this->tablesToDelete as $tableName => $true) {
$this->connection->dropTable($tableName);
+ foreach ($this->connection->getShardConnections() as $shardConnection) {
+ $shardConnection->dropTable($tableName);
+ }
unset($this->tablesToDelete[$tableName]);
}
}
@@ -62,7 +52,7 @@ class SchemaWrapper implements ISchemaWrapper {
public function getTableNamesWithoutPrefix() {
$tableNames = $this->schema->getTableNames();
return array_map(function ($tableName) {
- if (strpos($tableName, $this->connection->getPrefix()) === 0) {
+ if (str_starts_with($tableName, $this->connection->getPrefix())) {
return substr($tableName, strlen($this->connection->getPrefix()));
}