public function updateColumn($name, $datatype, $force = false)
    {
        if ($datatype instanceof Column) {
            $col = $datatype;
            $datatype = $col->type;
            $force = $col->passThrough;
        }
        if(!$force)
            $datatype = $this->findQuery($this->schema->dataTypes[strtoupper($datatype)]);
        $table = $this->db->quotekey($this->name);
        $column = $this->db->quotekey($name);
        if (preg_match('/sqlite2?/', $this->db->driver())){
            $this->rebuild_cmd['update'][$name] = isset($col)?$col:$datatype;
        } else {
            $dat = isset($col) ? $col->getColumnQuery() :
                $column.' '.$datatype;
            $cmd = array(
            'mysql' =>
                "ALTER TABLE $table MODIFY COLUMN $dat;",
            'pgsql' =>
                "ALTER TABLE $table ALTER COLUMN $column TYPE $datatype;",
            'sqlsrv|mssql|sybase|dblib|ibm' =>
                "ALTER TABLE $table ALTER COLUMN $column $datatype;",
            );
            if (isset($col)) {
                $cmd['pgsql'] = array($cmd['pgsql']);
                $cmd['pgsql'][] = "ALTER TABLE $table ALTER COLUMN $column SET DEFAULT ".$col->getDefault().";";
                if ($col->nullable)
                    $cmd['pgsql'][] = "ALTER TABLE $table ALTER COLUMN $column DROP NOT NULL;";
                else
                    $cmd['pgsql'][] = "ALTER TABLE $table ALTER COLUMN $column SET NOT NULL;";
                $df_key = 'DF_'.$this->name.'_'.$name;
                $cmd['sqlsrv|mssql|sybase|dblib|ibm'] = array(
                    "ALTER TABLE $table ALTER COLUMN $column $datatype ".$col->getNullable().";",
                    "DECLARE @ConstraintName nvarchar(200)
                    SELECT @ConstraintName = Name FROM SYS.DEFAULT_CONSTRAINTS WHERE PARENT_OBJECT_ID = OBJECT_ID('$this->name')
                     AND PARENT_COLUMN_ID = (SELECT column_id FROM sys.columns WHERE NAME = N'$name'
                     AND object_id = OBJECT_ID(N'$this->name'))
                    IF @ConstraintName IS NOT NULL
                    EXEC('ALTER TABLE $this->name DROP CONSTRAINT ' + @ConstraintName)
                    ",
                    "ALTER TABLE $table ADD CONSTRAINT $df_key DEFAULT ".$col->getDefault()." FOR $column;",
                );
            }
            $this->queries[] = $this->findQuery($cmd);
        }
    }
public function updateColumn($name, $datatype, $force = false)
    {
        if ($datatype instanceof Column) {
            $col = $datatype;
            $datatype = $col->type;
            $force = $col->passThrough;
        }
        if(!$force)
            $datatype = $this->findQuery($this->schema->dataTypes[strtoupper($datatype)]);
        $table = $this->db->quotekey($this->name);
        $column = $this->db->quotekey($name);
        if (preg_match('/sqlite2?/', $this->db->driver())){
            $this->rebuild_cmd['update'][$name] = isset($col)?$col:$datatype;
        } else {
            $dat = isset($col) ? $col->getColumnQuery() :
                $column.' '.$datatype;
            $cmd = array(
            'mysql' =>
                "ALTER TABLE $table MODIFY COLUMN $dat;",
            'pgsql' =>
                "ALTER TABLE $table ALTER COLUMN $column TYPE $datatype;",
            'sqlsrv|mssql|sybase|dblib|ibm' =>
                "ALTER TABLE $table ALTER COLUMN $column $datatype;",
            );
            if (isset($col)) {
                $cmd['pgsql'] = array($cmd['pgsql']);
                $cmd['pgsql'][] = "ALTER TABLE $table ALTER COLUMN $column SET DEFAULT ".$col->getDefault().";";
                if ($col->nullable)
                    $cmd['pgsql'][] = "ALTER TABLE $table ALTER COLUMN $column DROP NOT NULL;";
                else
                    $cmd['pgsql'][] = "ALTER TABLE $table ALTER COLUMN $column SET NOT NULL;";
                $df_key = 'DF_'.$this->name.'_'.$name;
                $cmd['sqlsrv|mssql|sybase|dblib|ibm'] = array(
                    "ALTER TABLE $table ALTER COLUMN $column $datatype ".$col->getNullable().";",
                    "DECLARE @ConstraintName nvarchar(200)
                    SELECT @ConstraintName = Name FROM SYS.DEFAULT_CONSTRAINTS WHERE PARENT_OBJECT_ID = OBJECT_ID('$this->name')
                     AND PARENT_COLUMN_ID = (SELECT column_id FROM sys.columns WHERE NAME = N'$name'
                     AND object_id = OBJECT_ID(N'$this->name'))
                    IF @ConstraintName IS NOT NULL
                    EXEC('ALTER TABLE $this->name DROP CONSTRAINT ' + @ConstraintName)
                    ",
                    "ALTER TABLE $table ADD CONSTRAINT $df_key DEFAULT ".$col->getDefault()." FOR $column;",
                );
            }
            $this->queries[] = $this->findQuery($cmd);
        }
    }
public function updateColumn ( $ name , $ datatype , $ force = false ) { if ( $ datatype instanceof Column ) { $ col = $ datatype ; $ datatype = $ col -> type ; $ force = $ col -> passThrough ; } if ( ! $ force ) $ datatype = $ this -> findQuery ( $ this -> schema -> dataTypes [ strtoupper ( $ datatype ) ] ) ; $ table = $ this -> db -> quotekey ( $ this -> name ) ; $ column = $ this -> db -> quotekey ( $ name ) ; if ( preg_match ( '/sqlite2?/' , $ this -> db -> driver ( ) ) ) { $ this -> rebuild_cmd [ 'update' ] [ $ name ] = isset ( $ col ) ? $ col : $ datatype ; } else { $ dat = isset ( $ col ) ? $ col -> getColumnQuery ( ) : $ column . ' ' . $ datatype ; $ cmd = array ( 'mysql' => "ALTER TABLE $table MODIFY COLUMN $dat;" , 'pgsql' => "ALTER TABLE $table ALTER COLUMN $column TYPE $datatype;" , 'sqlsrv|mssql|sybase|dblib|ibm' => "ALTER TABLE $table ALTER COLUMN $column $datatype;" , ) ; if ( isset ( $ col ) ) { $ cmd [ 'pgsql' ] = array ( $ cmd [ 'pgsql' ] ) ; $ cmd [ 'pgsql' ] [ ] = "ALTER TABLE $table ALTER COLUMN $column SET DEFAULT " . $ col -> getDefault ( ) . ";" ; if ( $ col -> nullable ) $ cmd [ 'pgsql' ] [ ] = "ALTER TABLE $table ALTER COLUMN $column DROP NOT NULL;" ; else $ cmd [ 'pgsql' ] [ ] = "ALTER TABLE $table ALTER COLUMN $column SET NOT NULL;" ; $ df_key = 'DF_' . $ this -> name . '_' . $ name ; $ cmd [ 'sqlsrv|mssql|sybase|dblib|ibm' ] = array ( "ALTER TABLE $table ALTER COLUMN $column $datatype " . $ col -> getNullable ( ) . ";" , "DECLARE @ConstraintName nvarchar(200)
                    SELECT @ConstraintName = Name FROM SYS.DEFAULT_CONSTRAINTS WHERE PARENT_OBJECT_ID = OBJECT_ID('$this->name')
                     AND PARENT_COLUMN_ID = (SELECT column_id FROM sys.columns WHERE NAME = N'$name'
                     AND object_id = OBJECT_ID(N'$this->name'))
                    IF @ConstraintName IS NOT NULL
                    EXEC('ALTER TABLE $this->name DROP CONSTRAINT ' + @ConstraintName)
                    " , "ALTER TABLE $table ADD CONSTRAINT $df_key DEFAULT " . $ col -> getDefault ( ) . " FOR $column;" , ) ; } $ this -> queries [ ] = $ this -> findQuery ( $ cmd ) ; } }
modifies column datatype
@param string $name
@param string|Column $datatype
@param bool $force
modifies column datatype