diff --git a/system/Database/OCI8/Forge.php b/system/Database/OCI8/Forge.php index 514cf99f41f4..5aea55928dbe 100644 --- a/system/Database/OCI8/Forge.php +++ b/system/Database/OCI8/Forge.php @@ -120,11 +120,14 @@ protected function _alterTable(string $alterType, string $table, $field) // If a null constraint is added to a column with a null constraint, // ORA-01451 will occur, // so add null constraint is used only when it is different from the current null constraint. - $isWantToAddNull = strpos($field[$i]['null'], ' NOT') === false; - $currentNullAddable = $nullableMap[$field[$i]['name']]; + $wantToAddNull = strpos($field[$i]['null'], ' NOT') === false; + $currentNullable = $nullableMap[$field[$i]['name']]; - if ($isWantToAddNull === $currentNullAddable) { + if ($wantToAddNull === true && $currentNullable === true) { $field[$i]['null'] = ''; + } elseif ($field[$i]['null'] === '' && $currentNullable === false) { + // Nullable by default + $field[$i]['null'] = ' NULL'; } }