Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix user_ldap migration for long DNs support
Signed-off-by: Côme Chilliet <[email protected]>
  • Loading branch information
come-nc authored and backportbot[bot] committed Jan 14, 2022
commit e4235bdebaf623d6ba16abdb04f89a267ad8682d
78 changes: 30 additions & 48 deletions apps/user_ldap/lib/Migration/Version1130Date20211102154716.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,12 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
$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;
Expand All @@ -91,50 +92,31 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
$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;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
$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, [
Expand Down