summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2019-07-11 19:40:04 +0200
committerGitHub <noreply@github.com>2019-07-11 19:40:04 +0200
commit74be0cf98229966438550d2272f92c9eba3aa58c (patch)
treeb450f96171ee90b9f21997e9ec2da64ba4260125
parent79e0b5c4ce313b85d26e5d0c9278d2336f185477 (diff)
parent0d4ca0e754bc9dfeffac68e80af33fff3713c915 (diff)
downloadnextcloud-server-74be0cf98229966438550d2272f92c9eba3aa58c.tar.gz
nextcloud-server-74be0cf98229966438550d2272f92c9eba3aa58c.zip
Merge pull request #16361 from nextcloud/bugfix/noid/drop-foreignkey-on-owncloud-migration
Drop foreignkey on owncloud migration
-rw-r--r--lib/private/Repair/Owncloud/SaveAccountsTableData.php24
1 files changed, 22 insertions, 2 deletions
diff --git a/lib/private/Repair/Owncloud/SaveAccountsTableData.php b/lib/private/Repair/Owncloud/SaveAccountsTableData.php
index c9e67356fb9..f62f8b56b26 100644
--- a/lib/private/Repair/Owncloud/SaveAccountsTableData.php
+++ b/lib/private/Repair/Owncloud/SaveAccountsTableData.php
@@ -44,6 +44,8 @@ class SaveAccountsTableData implements IRepairStep {
/** @var IConfig */
protected $config;
+ protected $hasForeignKeyOnPersistentLocks = false;
+
/**
* @param IDBConnection $db
* @param IConfig $config
@@ -77,6 +79,9 @@ class SaveAccountsTableData implements IRepairStep {
}
// Remove the table
+ if ($this->hasForeignKeyOnPersistentLocks) {
+ $this->db->dropTable('persistent_locks');
+ }
$this->db->dropTable('accounts');
}
@@ -85,14 +90,29 @@ class SaveAccountsTableData implements IRepairStep {
*/
protected function shouldRun() {
$schema = $this->db->createSchema();
+ $prefix = $this->config->getSystemValue('dbtableprefix', 'oc_');
- $tableName = $this->config->getSystemValue('dbtableprefix', 'oc_') . 'accounts';
+ $tableName = $prefix . 'accounts';
if (!$schema->hasTable($tableName)) {
return false;
}
$table = $schema->getTable($tableName);
- return $table->hasColumn('user_id');
+ if (!$table->hasColumn('user_id')) {
+ return false;
+ }
+
+ if ($schema->hasTable($prefix . 'persistent_locks')) {
+ $locksTable = $schema->getTable($prefix . 'persistent_locks');
+ $foreignKeys = $locksTable->getForeignKeys();
+ foreach ($foreignKeys as $foreignKey) {
+ if ($tableName === $foreignKey->getForeignTableName()) {
+ $this->hasForeignKeyOnPersistentLocks = true;
+ }
+ }
+ }
+
+ return true;
}
/**