diff options
author | Joas Schilling <coding@schilljs.com> | 2020-11-11 14:34:24 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2021-03-31 10:21:17 +0200 |
commit | 3696ef5b965e5d3e44197479eaf310e26288151c (patch) | |
tree | 003254ee3620f7c603dc3a8021b334aa0ffc40cc /lib/private/DB/MigrationService.php | |
parent | 133a6f4fe4f1ec1e80011301607264beab12c852 (diff) | |
download | nextcloud-server-3696ef5b965e5d3e44197479eaf310e26288151c.tar.gz nextcloud-server-3696ef5b965e5d3e44197479eaf310e26288151c.zip |
Don't allow Notnull for boolean columns
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/DB/MigrationService.php')
-rw-r--r-- | lib/private/DB/MigrationService.php | 5 |
1 files changed, 5 insertions, 0 deletions
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) { |