Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2020-11-11 16:34:24 +0300
committerJoas Schilling <coding@schilljs.com>2021-03-31 11:21:17 +0300
commit3696ef5b965e5d3e44197479eaf310e26288151c (patch)
tree003254ee3620f7c603dc3a8021b334aa0ffc40cc /lib/private
parent133a6f4fe4f1ec1e80011301607264beab12c852 (diff)
Don't allow Notnull for boolean columns
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/DB/MigrationService.php5
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) {