From 3696ef5b965e5d3e44197479eaf310e26288151c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 11 Nov 2020 14:34:24 +0100 Subject: Don't allow Notnull for boolean columns Signed-off-by: Joas Schilling --- lib/private/DB/MigrationService.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/private/DB/MigrationService.php') diff --git a/lib/private/DB/MigrationService.php b/lib/private/DB/MigrationService.php index 852ee8b701f..4957706bb1d 100644 --- a/lib/private/DB/MigrationService.php +++ b/lib/private/DB/MigrationService.php @@ -562,6 +562,7 @@ class MigrationService { * Data constraints: * - Columns with "NotNull" can not have empty string as default value * - Columns with "NotNull" can not have number 0 as default value + * - Columns with type "bool" (which is in fact integer of length 1) can not be "NotNull" as it can not store 0/false * * @param Schema $sourceSchema * @param Schema $targetSchema @@ -590,6 +591,10 @@ class MigrationService { && $sourceTable instanceof Table && !$sourceTable->hasColumn($thing->getName())) { throw new \InvalidArgumentException('Column "' . $table->getName() . '"."' . $thing->getName() . '" is NotNull, but has empty string or null as default.'); } + + if ($thing->getNotnull() && $thing->getType()->getName() === Types::BOOLEAN) { + throw new \InvalidArgumentException('Column "' . $table->getName() . '"."' . $thing->getName() . '" is type Bool and also NotNull, so it can not store "false".'); + } } foreach ($table->getIndexes() as $thing) { -- cgit v1.2.3