$sql = 'ALTER TABLE ' .
$this->db->
escapeIdentifiers($table);
if ($alterType === 'DROP'
) { $fields =
array_map(fn ($field) =>
$this->db->
escapeIdentifiers(trim($field)),
is_string($field) ?
explode(',',
$field) :
$field);
return $sql . ' DROP (' .
implode(',',
$fields) . ') CASCADE CONSTRAINT INVALIDATE';
} if ($alterType === 'CHANGE'
) { $alterType = 'MODIFY';
} $nullableMap =
array_column($this->db->
getFieldData($table), 'nullable', 'name'
);
$sqls =
[];
for ($i = 0,
$c =
count($field);
$i <
$c;
$i++
) { if ($alterType === 'MODIFY'
) { // 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.
// If a not null constraint is added to a column with a not null constraint,
// ORA-01442 will occur.
$wantToAddNull =
strpos($field[$i]['null'
], ' NOT'
) === false;
$currentNullable =
$nullableMap[$field[$i]['name'
]];