Doctrine\DBAL\Platforms\SQLServerPlatform::alterColumnRequiresDropDefaultConstraint PHP Method

alterColumnRequiresDropDefaultConstraint() private method

Different to other database vendors SQL Server implements column default values as constraints and therefore changes in a column's default value as well as changes in a column's type require dropping the default constraint first before being to alter the particular column to the new definition.
private alterColumnRequiresDropDefaultConstraint ( Doctrine\DBAL\Schema\ColumnDiff $columnDiff ) : boolean
$columnDiff Doctrine\DBAL\Schema\ColumnDiff The column diff to evaluate.
return boolean True if the column alteration requires dropping its default constraint first, false otherwise.
    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;
    }
SQLServerPlatform