diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2022-01-13 12:20:57 +0100 |
---|---|---|
committer | Côme Chilliet <come.chilliet@nextcloud.com> | 2022-01-13 14:06:59 +0100 |
commit | 7e4e919408f1c58ec037b66a7b15ba51627bc428 (patch) | |
tree | db20235a5a2ee5dd99b8c4a55a980d2d933435ca /apps/user_ldap/lib/Migration | |
parent | 23845755f2013adabea27550ed4dc6429ce4f326 (diff) | |
download | nextcloud-server-7e4e919408f1c58ec037b66a7b15ba51627bc428.tar.gz nextcloud-server-7e4e919408f1c58ec037b66a7b15ba51627bc428.zip |
Fix user_ldap migration for long DNs support
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'apps/user_ldap/lib/Migration')
-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 7ecf02d8f6f..b359f9fd357 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, [ |