diff options
author | Joas Schilling <coding@schilljs.com> | 2020-09-07 13:14:49 +0200 |
---|---|---|
committer | backportbot[bot] <backportbot[bot]@users.noreply.github.com> | 2020-09-07 19:00:03 +0000 |
commit | 54a5f938f9993fbfa00e4f261151912ebbcafaea (patch) | |
tree | 20baaa94b68f81250debe036cedc2d11bc439cc0 | |
parent | e80f566aeb5bbebe6f1b9fe6a67cf449931ddbff (diff) | |
download | nextcloud-server-54a5f938f9993fbfa00e4f261151912ebbcafaea.tar.gz nextcloud-server-54a5f938f9993fbfa00e4f261151912ebbcafaea.zip |
Warn about adding NotNull columns with nullable default
Signed-off-by: Joas Schilling <coding@schilljs.com>
-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 9f5b5bfe72b..d08f4fc75ce 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) { |