From: Joas Schilling Date: Mon, 7 Sep 2020 11:14:49 +0000 (+0200) Subject: Warn about adding NotNull columns with nullable default X-Git-Tag: v20.0.0beta4~43^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=50230847ce47133dd0be170457f24bf5e6ac4ab8;p=nextcloud-server.git Warn about adding NotNull columns with nullable default Signed-off-by: Joas Schilling --- diff --git a/lib/private/DB/MigrationService.php b/lib/private/DB/MigrationService.php index 42204dd155a..cd0280162d3 100644 --- a/lib/private/DB/MigrationService.php +++ b/lib/private/DB/MigrationService.php @@ -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) {