diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2022-01-13 12:20:57 +0100 |
---|---|---|
committer | backportbot[bot] <backportbot[bot]@users.noreply.github.com> | 2022-01-14 08:43:45 +0000 |
commit | 417e76cd2d413005d978f994f0b4b6f949d34219 (patch) | |
tree | 8f96d755b095e9faf9dd5a0052bf376b349595c8 | |
parent | a56ef49033c76762799a7a0533df36312ed32a25 (diff) | |
download | nextcloud-server-417e76cd2d413005d978f994f0b4b6f949d34219.tar.gz nextcloud-server-417e76cd2d413005d978f994f0b4b6f949d34219.zip |
Fix user_ldap migration for long DNs support
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
-rw-r--r-- | apps/user_ldap/lib/Migration/Version1130Date20211102154716.php | 78 | ||||
-rw-r--r-- | apps/user_ldap/lib/Migration/Version1130Date20220110154718.php | 2 |
2 files changed, 31 insertions, 49 deletions
diff --git a/apps/user_ldap/lib/Migration/Version1130Date20211102154716.php b/apps/user_ldap/lib/Migration/Version1130Date20211102154716.php index f464b132133..05c41760d6d 100644 --- a/apps/user_ldap/lib/Migration/Version1130Date20211102154716.php +++ b/apps/user_ldap/lib/Migration/Version1130Date20211102154716.php @@ -73,11 +73,12 @@ class Version1130Date20211102154716 extends SimpleMigrationStep { $changeSchema = true; } $column = $table->getColumn('ldap_dn'); - if ($column->getLength() < 4096) { - $column->setLength(4096); - $changeSchema = true; - } if ($tableName === 'ldap_user_mapping') { + if ($column->getLength() < 4096) { + $column->setLength(4096); + $changeSchema = true; + } + if ($table->hasIndex('ldap_dn_users')) { $table->dropIndex('ldap_dn_users'); $changeSchema = true; @@ -91,50 +92,31 @@ class Version1130Date20211102154716 extends SimpleMigrationStep { $changeSchema = true; } } else { - if ($table->hasIndex('owncloud_name_groups')) { - $table->dropIndex('owncloud_name_groups'); - $changeSchema = true; - } - if (!$table->hasIndex('ldap_group_dn_hashes')) { - $table->addUniqueIndex(['ldap_dn_hash'], 'ldap_group_dn_hashes'); - $changeSchema = true; - } - if (!$table->hasIndex('ldap_group_directory_uuid')) { - $table->addUniqueIndex(['directory_uuid'], 'ldap_group_directory_uuid'); - $changeSchema = true; - } - if (!$table->hasPrimaryKey()) { - $table->setPrimaryKey(['owncloud_name']); - $changeSchema = true; - } - - if ($table->getPrimaryKeyColumns() !== ['owncloud_name']) { - // 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, [ - 'notnull' => true, - 'length' => 255, - 'default' => '', - ]); - $table2->addColumn('owncloud_name', Types::STRING, [ - 'notnull' => true, - 'length' => 64, - 'default' => '', - ]); - $table2->addColumn('directory_uuid', Types::STRING, [ - 'notnull' => true, - 'length' => 255, - 'default' => '', - ]); - $table2->addColumn('ldap_dn_hash', Types::STRING, [ - 'notnull' => false, - 'length' => 64, - ]); - $table2->setPrimaryKey(['owncloud_name']); - $table2->addUniqueIndex(['ldap_dn_hash'], 'ldap_group_dn_hashes'); - $table2->addUniqueIndex(['directory_uuid'], 'ldap_group_directory_uuid'); - $changeSchema = true; - } + // 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, [ + 'notnull' => true, + 'length' => 4096, + 'default' => '', + ]); + $table2->addColumn('owncloud_name', Types::STRING, [ + 'notnull' => true, + 'length' => 64, + 'default' => '', + ]); + $table2->addColumn('directory_uuid', Types::STRING, [ + 'notnull' => true, + 'length' => 255, + 'default' => '', + ]); + $table2->addColumn('ldap_dn_hash', Types::STRING, [ + 'notnull' => false, + 'length' => 64, + ]); + $table2->setPrimaryKey(['owncloud_name'], 'lgm_backup_primary'); + $table2->addUniqueIndex(['ldap_dn_hash'], 'ldap_group_dn_hashes'); + $table2->addUniqueIndex(['directory_uuid'], 'ldap_group_directory_uuid'); + $changeSchema = true; } } diff --git a/apps/user_ldap/lib/Migration/Version1130Date20220110154718.php b/apps/user_ldap/lib/Migration/Version1130Date20220110154718.php index caadd9d9be2..5f146ab06a5 100644 --- a/apps/user_ldap/lib/Migration/Version1130Date20220110154718.php +++ b/apps/user_ldap/lib/Migration/Version1130Date20220110154718.php @@ -54,7 +54,7 @@ class Version1130Date20220110154718 extends GroupMappingMigration { $table = $schema->createTable('ldap_group_mapping'); $table->addColumn('ldap_dn', Types::STRING, [ 'notnull' => true, - 'length' => 255, + 'length' => 4096, 'default' => '', ]); $table->addColumn('owncloud_name', Types::STRING, [ |