]> source.dussan.org Git - nextcloud-server.git/commitdiff
Warn about adding NotNull columns with nullable default 22643/head
authorJoas Schilling <coding@schilljs.com>
Mon, 7 Sep 2020 11:14:49 +0000 (13:14 +0200)
committerJoas Schilling <coding@schilljs.com>
Mon, 7 Sep 2020 11:14:49 +0000 (13:14 +0200)
Signed-off-by: Joas Schilling <coding@schilljs.com>
lib/private/DB/MigrationService.php

index 42204dd155aa1cf0c4b9478d01ff520798e7397f..cd0280162d3826bb495c40df83e24ed16d7dba43 100644 (file)
@@ -513,6 +513,11 @@ class MigrationService {
                                if ((!$sourceTable instanceof Table || !$sourceTable->hasColumn($thing->getName())) && \strlen($thing->getName()) > 30) {
                                        throw new \InvalidArgumentException('Column name "'  . $table->getName() . '"."' . $thing->getName() . '" is too long.');
                                }
+
+                               if ($thing->getNotnull() && $thing->getDefault() === ''
+                                       && $sourceTable instanceof Table && !$sourceTable->hasColumn($thing->getName())) {
+                                       throw new \InvalidArgumentException('Column name "'  . $table->getName() . '"."' . $thing->getName() . '" is NotNull, but has empty string or null as default.');
+                               }
                        }
 
                        foreach ($table->getIndexes() as $thing) {