Detects and rewrites renamed columns.

@param array &$createdColumns The create columns.
@param array &$droppedColumns The dropped columns.
@param array &$alteredColumns The altered columns.
9340
private function detectRenamedColumns(array &$createdColumns, array &$droppedColumns, array &$alteredColumns)
    {
        foreach ($createdColumns as $createdIndex => $createdColumn) {
            foreach ($droppedColumns as $droppedIndex => $droppedColumn) {
                $columnDiff = $this->columnComparator->compare($droppedColumn, $createdColumn);

                if ($columnDiff->hasNameDifferenceOnly()) {
                    $alteredColumns[] = $columnDiff;

                    unset($createdColumns[$createdIndex]);
                    unset($droppedColumns[$droppedIndex]);

                    break;
                }
            }
        }
    }
1317680
protected function adjustDiffs(array $protectedTableNames)
    {
        $diffUpdater = new DiffUpdater($this->ignoredChanges);

        /** @var TableDiff $tableDiff */
        foreach ($this->diffs as $tableName => $tableDiff) {
            $this->adjustContentTypeDiffs($tableDiff, $protectedTableNames);
            $this->diffs[$tableName] = $diffUpdater->adjustDiff($tableDiff);
            if ($this->diffs[$tableName] === false) {
                unset($this->diffs[$tableName]);
                continue;
            }
        }
    }
1335793
def _get_column_names_in_altered_table(self, diff):
        
        columns = OrderedDict()

        for column_name, column in diff.from_table.get_columns().items():
            columns[column_name.lower()] = column.get_name()

        for column_name, column in diff.removed_columns.items():
            column_name = column_name.lower()
            if column_name in columns:
                del columns[column_name]

        for old_column_name, column in diff.renamed_columns.items():
            column_name = column.get_name()
            columns[old_column_name.lower()] = column_name
            columns[column_name.lower()] = column_name

        for old_column_name, column_diff in diff.changed_columns.items():
            column_name = column_diff.column.get_name()
            columns[old_column_name.lower()] = column_name
            columns[column_name.lower()] = column_name

        for column_name, column in diff.added_columns.items():
            columns[column_name.lower()] = column_name

        return columns
1209356
private function getChangedColumns($tableName, TableDiff $diff)
    {
        /** @var $col \Doctrine\DBAL\Schema\ColumnDiff */
        foreach ($diff->changedColumns as $col) {
            $this->addMessage($tableName, sprintf('invalid column `%s`', $col->oldColumnName));
        }
    }
1364188
private void alterColumn(AlterTableOptions alterTableOptions, Schema schema, ColumnInfo columnInfo,
            AtomicBoolean updated)
    {
        if (!KuduDBDataHandler.hasColumn(schema, columnInfo.getColumnName()))
        {
            // add if column is not in schema
            alterTableOptions.addNullableColumn(columnInfo.getColumnName(),
                    KuduDBValidationClassMapper.getValidTypeForClass(columnInfo.getType()));
            updated.set(true);
        }
        else
        {
            // check for type, drop and add if not consistent TODO: throw
            // exception or override?
            if (!schema.getColumn(columnInfo.getColumnName()).getType()
                    .equals(KuduDBValidationClassMapper.getValidTypeForClass(columnInfo.getType())))
            {
                alterTableOptions.dropColumn(columnInfo.getColumnName());
                alterTableOptions.addNullableColumn(columnInfo.getColumnName(),
                        KuduDBValidationClassMapper.getValidTypeForClass(columnInfo.getType()));
                updated.set(true);
            }
        }
    }
288743
public function forColumns(array $columnNames) : FinalizedObjectTableDefinition
    {
        $columns = [];

        foreach ($columnNames as $columnName) {
            $columns[$columnName] = $this->structure->getColumn($columnName);
        }

        $columnNames            = array_fill_keys($columnNames, true);
        $propertyComponentIdMap = [];
        $indexComponentIdMap    = [];
        $componentIdCallableMap = [];

        foreach ($this->propertyComponentIdMap as $property => $componentId) {
            $column = $this->getColumnNameFromComponentId($componentId);

            if (isset($columnNames[$column])) {
                $propertyComponentIdMap[$property] = $componentId;
            }
        }

        foreach ($this->indexComponentIdMap as $componentId) {
            $column = $this->getColumnNameFromComponentId($componentId);

            if (isset($columnNames[$column])) {
                $indexComponentIdMap[] = $componentId;
            }
        }

        foreach ($this->componentIdCallableMap as $componentId => $callable) {
            $column = $this->getColumnNameFromComponentId($componentId);

            if (isset($columnNames[$column])) {
                $componentIdCallableMap[$componentId] = $callable;
            }
        }

        return new self(
            $this->class,
            $this->structure->withColumns($columns),
            $propertyComponentIdMap,
            $indexComponentIdMap,
            $componentIdCallableMap,
            $this->customCallableMappers
        );
    }
535691
public function alteredColumns(): array
    {
        $difference = [];

        $initialColumns = $this->initial->getColumns();
        foreach ($this->current->getColumns() as $name => $column) {
            if (!isset($initialColumns[$name])) {
                //Added into schema
                continue;
            }

            if (!$column->compare($initialColumns[$name])) {
                $difference[] = [$column, $initialColumns[$name]];
            }
        }

        return $difference;
    }
556616
public function setRemovedColumns(array $removedColumns)
    {
        $this->removedColumns = [];
        foreach ($removedColumns as $removedColumn) {
            $this->addRemovedColumn($removedColumn->getName(), $removedColumn);
        }
    }
351273
private function buildColumnResets(array $definition, Column $column, string $size, array $sizes): void
    {
        switch ($definition['reset']) {
            case '2':
                $key  = array_search($size, $sizes);
                $next = ($sizes[($key + 1)] ?? null);

                if ($next) {
                    $column->limitedReset((string) $next);

                    break;
                }

                // No break here,
            case '1':
                $column->reset();
                break;

            default:
                // Do nothing.
        }
    }
1011374
function renameColumn(from, to) {
    this._statements.push({
      grouping: 'alterTable',
      method: 'renameColumn',
      args: [from, to]
    });
    return this;
  }
25952
private function getRenamedColumns($tableName, TableDiff $diff)
    {
        foreach (array_keys($diff->renamedColumns) as $colName) {
            $this->addMessage($tableName, sprintf('renamed column `%s`', $colName));
        }
    }
618796
public function setColumnHeaders(array $columnHeaders)
    {
        $this->columnHeaders = array_count_values($columnHeaders);
        $this->headersCount = count($columnHeaders);
    }
498552
protected function _droppedColumnsStatement()
    {
        $columns = $this->_sql->getDroppedColumns();
        if (empty($columns)) {
            return null;
        }

        return implode(', ', array_keys($columns));
    }
365893
public static function renameColumn($table, $oldColumn, $newColumn)
    {
        $column = [$oldColumn, $newColumn];

        return static::alterColumn('RENAME', $table, $column);
    }
681293
protected static function buildValuesList(array $updatedColumns)
    {
        $out = [];

        foreach ($updatedColumns as $key => $value) {
            if (is_numeric($key)) {
                $out[] = sprintf('`%s` = VALUES(`%s`)', $value, $value);
            } else {
                $out[] = sprintf('%s = %s', $key, $value);
            }
        }

        return implode(', ', $out);
    }
289041
final public function updateColumns(array $data, array $allowedColumns = array())
    {
        foreach ($data as $column => $values) {
            foreach ($values as $id => $value) {
                // Protection. Update only defined columns
                if (!empty($allowedColumns) && !in_array($column, $allowedColumns)) {
                    continue;
                }

                $this->updateColumnByPk($id, $column, $value);
            }
        }

        return true;
    }
1151857
public static function renameColumns($tableName, array $columnNames)
    {
        return [
            'up' => function (Builder $schema) use ($tableName, $columnNames) {
                $schema->table($tableName, function (Blueprint $table) use ($columnNames) {
                    foreach ($columnNames as $from => $to) {
                        $table->renameColumn($from, $to);
                    }
                });
            },
            'down' => function (Builder $schema) use ($tableName, $columnNames) {
                $schema->table($tableName, function (Blueprint $table) use ($columnNames) {
                    foreach ($columnNames as $to => $from) {
                        $table->renameColumn($from, $to);
                    }
                });
            }
        ];
    }