src/Driver/SQLServer/SQLServerHandler.php
public function alterColumn(
        AbstractTable $table,
        AbstractColumn $initial,
        AbstractColumn $column
    ) {
        if (!$initial instanceof SQLServerColumn || !$column instanceof SQLServerColumn) {
            throw new SchemaException('SQlServer handler can work only with SQLServer columns');
        }

        //In SQLServer we have to drop ALL related indexes and foreign keys while
        //applying type change... yeah...

        $indexesBackup = [];
        $foreignBackup = [];
        foreach ($table->getIndexes() as $index) {
            if (in_array($column->getName(), $index->getColumns())) {
                $indexesBackup[] = $index;
                $this->dropIndex($table, $index);
            }
        }

        foreach ($table->getForeignKeys() as $foreign) {
            if ($column->getName() == $foreign->getColumn()) {
                $foreignBackup[] = $foreign;
                $this->dropForeignKey($table, $foreign);
            }
        }

        //Column will recreate needed constraints
        foreach ($column->getConstraints() as $constraint) {
            $this->dropConstrain($table, $constraint);
        }

        //Rename is separate operation
        if ($column->getName() != $initial->getName()) {
            $this->renameColumn($table, $initial, $column);

            //This call is required to correctly built set of alter operations
            $initial->setName($column->getName());
        }

        foreach ($column->alterOperations($this->driver, $initial) as $operation) {
            $this->run("ALTER TABLE {$this->identify($table)} {$operation}");
        }

        //Restoring indexes and foreign keys
        foreach ($indexesBackup as $index) {
            $this->createIndex($table, $index);
        }

        foreach ($foreignBackup as $foreign) {
            $this->createForeignKey($table, $foreign);
        }
    }
public function alterColumn(
        AbstractTable $table,
        AbstractColumn $initial,
        AbstractColumn $column
    ) {
        if (!$initial instanceof SQLServerColumn || !$column instanceof SQLServerColumn) {
            throw new SchemaException('SQlServer handler can work only with SQLServer columns');
        }

        //In SQLServer we have to drop ALL related indexes and foreign keys while
        //applying type change... yeah...

        $indexesBackup = [];
        $foreignBackup = [];
        foreach ($table->getIndexes() as $index) {
            if (in_array($column->getName(), $index->getColumns())) {
                $indexesBackup[] = $index;
                $this->dropIndex($table, $index);
            }
        }

        foreach ($table->getForeignKeys() as $foreign) {
            if ($column->getName() == $foreign->getColumn()) {
                $foreignBackup[] = $foreign;
                $this->dropForeignKey($table, $foreign);
            }
        }

        //Column will recreate needed constraints
        foreach ($column->getConstraints() as $constraint) {
            $this->dropConstrain($table, $constraint);
        }

        //Rename is separate operation
        if ($column->getName() != $initial->getName()) {
            $this->renameColumn($table, $initial, $column);

            //This call is required to correctly built set of alter operations
            $initial->setName($column->getName());
        }

        foreach ($column->alterOperations($this->driver, $initial) as $operation) {
            $this->run("ALTER TABLE {$this->identify($table)} {$operation}");
        }

        //Restoring indexes and foreign keys
        foreach ($indexesBackup as $index) {
            $this->createIndex($table, $index);
        }

        foreach ($foreignBackup as $foreign) {
            $this->createForeignKey($table, $foreign);
        }
    }
public function alterColumn ( AbstractTable $ table , AbstractColumn $ initial , AbstractColumn $ column ) { if ( ! $ initial instanceof SQLServerColumn || ! $ column instanceof SQLServerColumn ) { throw new SchemaException ( 'SQlServer handler can work only with SQLServer columns' ) ; } //In SQLServer we have to drop ALL related indexes and foreign keys while //applying type change... yeah... $ indexesBackup = [ ] ; $ foreignBackup = [ ] ; foreach ( $ table -> getIndexes ( ) as $ index ) { if ( in_array ( $ column -> getName ( ) , $ index -> getColumns ( ) ) ) { $ indexesBackup [ ] = $ index ; $ this -> dropIndex ( $ table , $ index ) ; } } foreach ( $ table -> getForeignKeys ( ) as $ foreign ) { if ( $ column -> getName ( ) == $ foreign -> getColumn ( ) ) { $ foreignBackup [ ] = $ foreign ; $ this -> dropForeignKey ( $ table , $ foreign ) ; } } //Column will recreate needed constraints foreach ( $ column -> getConstraints ( ) as $ constraint ) { $ this -> dropConstrain ( $ table , $ constraint ) ; } //Rename is separate operation if ( $ column -> getName ( ) != $ initial -> getName ( ) ) { $ this -> renameColumn ( $ table , $ initial , $ column ) ; //This call is required to correctly built set of alter operations $ initial -> setName ( $ column -> getName ( ) ) ; } foreach ( $ column -> alterOperations ( $ this -> driver , $ initial ) as $ operation ) { $ this -> run ( "ALTER TABLE {$this->identify($table)} {$operation}" ) ; } //Restoring indexes and foreign keys foreach ( $ indexesBackup as $ index ) { $ this -> createIndex ( $ table , $ index ) ; } foreach ( $ foreignBackup as $ foreign ) { $ this -> createForeignKey ( $ table , $ foreign ) ; } }
Driver specific column alter command.

@param AbstractTable  $table
@param AbstractColumn $initial
@param AbstractColumn $column

@throws SchemaException
Driver specific column alter command .