src/Driver/SQLServer/Schema/SQLServerColumn.php
public function alterOperations(DriverInterface $driver, AbstractColumn $initial): array
    {
        $operations = [];

        $currentType = [
            $this->type,
            $this->size,
            $this->precision,
            $this->scale,
            $this->nullable,
        ];

        $initType = [
            $initial->type,
            $initial->size,
            $initial->precision,
            $initial->scale,
            $initial->nullable,
        ];

        if ($currentType != $initType) {
            if ($this->getAbstractType() == 'enum') {
                //Getting longest value
                $enumSize = $this->size;
                foreach ($this->enumValues as $value) {
                    $enumSize = max($enumSize, strlen($value));
                }

                $type = "ALTER COLUMN {$driver->identifier($this->getName())} varchar($enumSize)";
                $operations[] = $type . ' ' . ($this->nullable ? 'NULL' : 'NOT NULL');
            } else {
                $type = "ALTER COLUMN {$driver->identifier($this->getName())} {$this->type}";

                if (!empty($this->size)) {
                    $type .= "($this->size)";
                } elseif ($this->type == 'varchar' || $this->type == 'varbinary') {
                    $type .= '(max)';
                } elseif (!empty($this->precision)) {
                    $type .= "($this->precision, $this->scale)";
                }

                $operations[] = $type . ' ' . ($this->nullable ? 'NULL' : 'NOT NULL');
            }
        }

        //Constraint should be already removed it this moment (see doColumnChange in TableSchema)
        if ($this->hasDefaultValue()) {
            $operations[] = "ADD CONSTRAINT {$this->defaultConstrain()} "
                . "DEFAULT {$this->quoteDefault($driver)} "
                . "FOR {$driver->identifier($this->getName())}";
        }

        //Constraint should be already removed it this moment (see alterColumn in SQLServerHandler)
        if ($this->getAbstractType() == 'enum') {
            $operations[] = "ADD {$this->enumStatement($driver)}";
        }

        return $operations;
    }
public function alterOperations(DriverInterface $driver, AbstractColumn $initial): array
    {
        $operations = [];

        $currentType = [
            $this->type,
            $this->size,
            $this->precision,
            $this->scale,
            $this->nullable,
        ];

        $initType = [
            $initial->type,
            $initial->size,
            $initial->precision,
            $initial->scale,
            $initial->nullable,
        ];

        if ($currentType != $initType) {
            if ($this->getAbstractType() == 'enum') {
                //Getting longest value
                $enumSize = $this->size;
                foreach ($this->enumValues as $value) {
                    $enumSize = max($enumSize, strlen($value));
                }

                $type = "ALTER COLUMN {$driver->identifier($this->getName())} varchar($enumSize)";
                $operations[] = $type . ' ' . ($this->nullable ? 'NULL' : 'NOT NULL');
            } else {
                $type = "ALTER COLUMN {$driver->identifier($this->getName())} {$this->type}";

                if (!empty($this->size)) {
                    $type .= "($this->size)";
                } elseif ($this->type == 'varchar' || $this->type == 'varbinary') {
                    $type .= '(max)';
                } elseif (!empty($this->precision)) {
                    $type .= "($this->precision, $this->scale)";
                }

                $operations[] = $type . ' ' . ($this->nullable ? 'NULL' : 'NOT NULL');
            }
        }

        //Constraint should be already removed it this moment (see doColumnChange in TableSchema)
        if ($this->hasDefaultValue()) {
            $operations[] = "ADD CONSTRAINT {$this->defaultConstrain()} "
                . "DEFAULT {$this->quoteDefault($driver)} "
                . "FOR {$driver->identifier($this->getName())}";
        }

        //Constraint should be already removed it this moment (see alterColumn in SQLServerHandler)
        if ($this->getAbstractType() == 'enum') {
            $operations[] = "ADD {$this->enumStatement($driver)}";
        }

        return $operations;
    }
public function alterOperations ( DriverInterface $ driver , AbstractColumn $ initial ) : array { $ operations = [ ] ; $ currentType = [ $ this -> type , $ this -> size , $ this -> precision , $ this -> scale , $ this -> nullable , ] ; $ initType = [ $ initial -> type , $ initial -> size , $ initial -> precision , $ initial -> scale , $ initial -> nullable , ] ; if ( $ currentType != $ initType ) { if ( $ this -> getAbstractType ( ) == 'enum' ) { //Getting longest value $ enumSize = $ this -> size ; foreach ( $ this -> enumValues as $ value ) { $ enumSize = max ( $ enumSize , strlen ( $ value ) ) ; } $ type = "ALTER COLUMN {$driver->identifier($this->getName())} varchar($enumSize)" ; $ operations [ ] = $ type . ' ' . ( $ this -> nullable ? 'NULL' : 'NOT NULL' ) ; } else { $ type = "ALTER COLUMN {$driver->identifier($this->getName())} {$this->type}" ; if ( ! empty ( $ this -> size ) ) { $ type .= "($this->size)" ; } elseif ( $ this -> type == 'varchar' || $ this -> type == 'varbinary' ) { $ type .= '(max)' ; } elseif ( ! empty ( $ this -> precision ) ) { $ type .= "($this->precision, $this->scale)" ; } $ operations [ ] = $ type . ' ' . ( $ this -> nullable ? 'NULL' : 'NOT NULL' ) ; } } //Constraint should be already removed it this moment (see doColumnChange in TableSchema) if ( $ this -> hasDefaultValue ( ) ) { $ operations [ ] = "ADD CONSTRAINT {$this->defaultConstrain()} " . "DEFAULT {$this->quoteDefault($driver)} " . "FOR {$driver->identifier($this->getName())}" ; } //Constraint should be already removed it this moment (see alterColumn in SQLServerHandler) if ( $ this -> getAbstractType ( ) == 'enum' ) { $ operations [ ] = "ADD {$this->enumStatement($driver)}" ; } return $ operations ; }
Generate set of operations need to change column. We are expecting that column constrains
will be dropped separately.

@param DriverInterface $driver
@param AbstractColumn  $initial
@return array
Generate set of operations need to change column . We are expecting that column constrains will be dropped separately .