]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fixes in migration step
authorCôme Chilliet <come.chilliet@nextcloud.com>
Thu, 4 Nov 2021 14:38:01 +0000 (15:38 +0100)
committerCôme Chilliet <come.chilliet@nextcloud.com>
Mon, 13 Dec 2021 08:39:33 +0000 (09:39 +0100)
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>
apps/user_ldap/lib/Migration/Version1130Date20211102154716.php

index 198a79ef09516c8e0f58d228439f02b37e07b597..829e0d5a58c960abde3e6f06fded6cfbb8bf6187 100644 (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;