summaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/lib/Migration
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2022-02-02 18:26:31 +0100
committerCôme Chilliet <come.chilliet@nextcloud.com>2022-02-10 10:14:59 +0100
commit601ce05dab6515e935bd040afd232af1fb2d54b3 (patch)
tree11dbf359b9ea9506cd0eddeaf9f1ae4eb8014435 /apps/user_ldap/lib/Migration
parent71fb44953e216affbe98c6c8c7106e1d62ee33fd (diff)
downloadnextcloud-server-601ce05dab6515e935bd040afd232af1fb2d54b3.tar.gz
nextcloud-server-601ce05dab6515e935bd040afd232af1fb2d54b3.zip
allow to re-run migration step when backup DB is already created
- to heal incomplete states from broken upgrades Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/user_ldap/lib/Migration')
-rw-r--r--apps/user_ldap/lib/Migration/Version1130Date20211102154716.php13
1 files changed, 12 insertions, 1 deletions
diff --git a/apps/user_ldap/lib/Migration/Version1130Date20211102154716.php b/apps/user_ldap/lib/Migration/Version1130Date20211102154716.php
index 94f0f0aa82e..27f5f5ce504 100644
--- a/apps/user_ldap/lib/Migration/Version1130Date20211102154716.php
+++ b/apps/user_ldap/lib/Migration/Version1130Date20211102154716.php
@@ -57,6 +57,17 @@ class Version1130Date20211102154716 extends SimpleMigrationStep {
foreach (['ldap_user_mapping', 'ldap_group_mapping'] as $tableName) {
$this->processDuplicateUUIDs($tableName);
}
+
+ /** @var ISchemaWrapper $schema */
+ $schema = $schemaClosure();
+ if ($schema->hasTable('ldap_group_mapping_backup')) {
+ // Previous upgrades of a broken release might have left an incomplete
+ // ldap_group_mapping_backup table. No need to recreate, but it
+ // should be empty.
+ // TRUNCATE is not available from Query Builder, but faster than DELETE FROM.
+ $sql = $this->dbc->getDatabasePlatform()->getTruncateTableSQL('ldap_group_mapping_backup', false);
+ $this->dbc->executeStatement($sql);
+ }
}
/**
@@ -98,7 +109,7 @@ class Version1130Date20211102154716 extends SimpleMigrationStep {
$table->addUniqueIndex(['directory_uuid'], 'ldap_user_directory_uuid');
$changeSchema = true;
}
- } else {
+ } else if (!$schema->hasTable('ldap_group_mapping_backup')) {
// We need to copy the table twice to be able to change primary key, prepare the backup table
$table2 = $schema->createTable('ldap_group_mapping_backup');
$table2->addColumn('ldap_dn', Types::STRING, [