From 5e3c4f96090e926916b06a52580bbba2a60a4555 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 7 Sep 2020 11:55:03 +0200 Subject: [PATCH 1/2] Fix installing on Oracle Empty strings are stored as null in Oracle, so a column with NotNull can not have an empty string as default Signed-off-by: Joas Schilling --- core/Migrations/Version18000Date20190920085628.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/Migrations/Version18000Date20190920085628.php b/core/Migrations/Version18000Date20190920085628.php index 96fcfc7ab8153..0e83855d55bcd 100644 --- a/core/Migrations/Version18000Date20190920085628.php +++ b/core/Migrations/Version18000Date20190920085628.php @@ -60,7 +60,9 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt $table->addColumn('displayname', Types::STRING, [ 'notnull' => true, 'length' => 255, - 'default' => '', + // Will be overwritten in postSchemaChange, but Oracle can not save + // empty strings in notnull columns + 'default' => 'name', ]); } From 50230847ce47133dd0be170457f24bf5e6ac4ab8 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 7 Sep 2020 13:14:49 +0200 Subject: [PATCH 2/2] Warn about adding NotNull columns with nullable default Signed-off-by: Joas Schilling --- lib/private/DB/MigrationService.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/private/DB/MigrationService.php b/lib/private/DB/MigrationService.php index 42204dd155aa1..cd0280162d382 100644 --- a/lib/private/DB/MigrationService.php +++ b/lib/private/DB/MigrationService.php @@ -513,6 +513,11 @@ public function ensureOracleIdentifierLengthLimit(Schema $sourceSchema, Schema $ 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) {