summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2020-09-07 13:14:49 +0200
committerJoas Schilling <coding@schilljs.com>2020-09-07 13:14:49 +0200
commit50230847ce47133dd0be170457f24bf5e6ac4ab8 (patch)
tree811e15e80526104328a9114ffea907d72991c020
parent5e3c4f96090e926916b06a52580bbba2a60a4555 (diff)
downloadnextcloud-server-50230847ce47133dd0be170457f24bf5e6ac4ab8.tar.gz
nextcloud-server-50230847ce47133dd0be170457f24bf5e6ac4ab8.zip
Warn about adding NotNull columns with nullable default
Signed-off-by: Joas Schilling <coding@schilljs.com>
-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 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) {