private function alterColumnRequiresDropDefaultConstraint(ColumnDiff $columnDiff)
{
// We can only decide whether to drop an existing default constraint
// if we know the original default value.
if (!$columnDiff->fromColumn instanceof Column) {
return false;
}
// We only need to drop an existing default constraint if we know the
// column was defined with a default value before.
if ($columnDiff->fromColumn->getDefault() === null) {
return false;
}
// We need to drop an existing default constraint if the column was
// defined with a default value before and it has changed.
if ($columnDiff->hasChanged('default')) {
return true;
}
// We need to drop an existing default constraint if the column was
// defined with a default value before and the native column type has changed.
if ($columnDiff->hasChanged('type') || $columnDiff->hasChanged('fixed')) {
return true;
}
return false;
}