mirror of
https://github.com/nextcloud/server.git
synced 2026-03-21 01:52:08 -04:00
Fix user_ldap migration for long DNs support
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
parent
9a13fb0b0e
commit
488e17cd44
2 changed files with 31 additions and 49 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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, [
|
||||
|
|
|
|||
Loading…
Reference in a new issue