src/Db/MySqlDb.php
protected function alterTable($tablename, array $alterdef, array $options = []) {
        $columnOrders = $this->getColumnOrders($alterdef['def']['columns']);
        $parts = [];

        // Add the columns and indexes.
        foreach ($alterdef['add']['columns'] as $cname => $cdef) {
            // Figure out the order of the column.
            $pos = val($cname, $columnOrders, '');
            $parts[] = 'add '.$this->columnDefString($cname, $cdef).$pos;
        }
        foreach ($alterdef['add']['indexes'] as $ixdef) {
            $parts[] = 'add '.$this->indexDefString($tablename, $ixdef);
        }

        // Alter the columns.
        foreach ($alterdef['alter']['columns'] as $cname => $cdef) {
            $parts[] = 'modify '.$this->columnDefString($cname, $cdef);
        }

        // Drop the columns and indexes.
        foreach ($alterdef['drop']['columns'] as $cname => $_) {
            $parts[] = 'drop '.$this->backtick($cname);
        }
        foreach ($alterdef['drop']['indexes'] as $ixdef) {
            $parts[] = 'drop index '.$this->backtick($ixdef['name']);
        }

        if (empty($parts)) {
            return false;
        }

        $sql = 'alter '.
            (val(Db::OPTION_IGNORE, $options) ? 'ignore ' : '').
            'table '.$this->backtick($this->px.$tablename)."\n  ".
            implode(",\n  ", $parts);

        $result = $this->query($sql, Db::QUERY_DEFINE);
        return $result;
    }
protected function alterTable($tablename, array $alterdef, array $options = []) {
        $columnOrders = $this->getColumnOrders($alterdef['def']['columns']);
        $parts = [];

        // Add the columns and indexes.
        foreach ($alterdef['add']['columns'] as $cname => $cdef) {
            // Figure out the order of the column.
            $pos = val($cname, $columnOrders, '');
            $parts[] = 'add '.$this->columnDefString($cname, $cdef).$pos;
        }
        foreach ($alterdef['add']['indexes'] as $ixdef) {
            $parts[] = 'add '.$this->indexDefString($tablename, $ixdef);
        }

        // Alter the columns.
        foreach ($alterdef['alter']['columns'] as $cname => $cdef) {
            $parts[] = 'modify '.$this->columnDefString($cname, $cdef);
        }

        // Drop the columns and indexes.
        foreach ($alterdef['drop']['columns'] as $cname => $_) {
            $parts[] = 'drop '.$this->backtick($cname);
        }
        foreach ($alterdef['drop']['indexes'] as $ixdef) {
            $parts[] = 'drop index '.$this->backtick($ixdef['name']);
        }

        if (empty($parts)) {
            return false;
        }

        $sql = 'alter '.
            (val(Db::OPTION_IGNORE, $options) ? 'ignore ' : '').
            'table '.$this->backtick($this->px.$tablename)."\n  ".
            implode(",\n  ", $parts);

        $result = $this->query($sql, Db::QUERY_DEFINE);
        return $result;
    }
{@inheritdoc}