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>
$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;
}
$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;