From 1031170f35dea164c0b06020376572cb4ec337dc Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 7 Sep 2020 13:14:49 +0200 Subject: [PATCH] Warn about adding NotNull columns with nullable default Signed-off-by: Joas Schilling --- lib/private/DB/MigrationService.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/private/DB/MigrationService.php b/lib/private/DB/MigrationService.php index 6685c1917f..b30d3eb8a0 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) {