Fixes in migration step

We cannot set ldap_dn_hash column as notnull because it is empty for
 existing users before postSchemaChange is called

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
Côme Chilliet 2021-11-04 15:38:01 +01:00
parent 581b1d8da6
commit aa65a4fe90
No known key found for this signature in database
GPG key ID: A3E2F658B28C760A

View file

@ -45,9 +45,8 @@ class Version1130Date20211102154716 extends SimpleMigrationStep {
$table = $schema->getTable($tableName);
if (!$table->hasColumn('ldap_dn_hash')) {
$table->addColumn('ldap_dn_hash', Types::STRING, [
'notnull' => true,
'notnull' => false,
'length' => 64,
'default' => '',
]);
$changeSchema = true;
}
@ -74,7 +73,7 @@ class Version1130Date20211102154716 extends SimpleMigrationStep {
$table->addUniqueIndex(['ldap_dn_hash'], 'ldap_group_dn_hashes');
$changeSchema = true;
}
if ($table->getPrimaryKeyColumns() !== ['owncloud_name']) {
if (!$table->hasPrimaryKey() || ($table->getPrimaryKeyColumns() !== ['owncloud_name'])) {
$table->dropPrimaryKey();
$table->setPrimaryKey(['owncloud_name']);
$changeSchema = true;