Renames a tabled field and does some plausibility checks.

@param  string $table
@param  string $oldFieldName
@param  string $newFieldName
@return int
773973
protected function renameDatabaseTableField($table, $oldFieldName, $newFieldName)
    {
        $title = 'Renaming "' . $table . ':' . $oldFieldName . '" to "' . $table . ':' . $newFieldName . '": ';

        $currentTableFields = $this->databaseConnection->admin_get_fields($table);

        if ($currentTableFields[$newFieldName]) {
            $message = 'Field ' . $table . ':' . $newFieldName . ' already existing.';
            $status = FlashMessage::OK;
        } else {
            if (!$currentTableFields[$oldFieldName]) {
                $message = 'Field ' . $table . ':' . $oldFieldName . ' not existing';
                $status = FlashMessage::ERROR;
            } else {
                $sql = 'ALTER TABLE ' . $table . ' CHANGE COLUMN ' . $oldFieldName . ' ' . $newFieldName . ' ' .
                    $currentTableFields[$oldFieldName]['Type'];

                if ($this->databaseConnection->admin_query($sql) === false) {
                    $message = ' SQL ERROR: ' . $this->databaseConnection->sql_error();
                    $status = FlashMessage::ERROR;
                } else {
                    $message = 'OK!';
                    $status = FlashMessage::OK;
                }
            }
        }

        $this->addMessage($status, $title, $message);

        return $status;
    }
1358464
public function renameCollection($newname) {

        if (!in_array($newname, $this->database->getCollectionNames())) {

            $this->database->connection->exec('ALTER TABLE '.$this->name.' RENAME TO '.$newname);

            $this->name = $newname;

            return true;
        }

        return false;
    }
530890
public function renameTable($old, $new)
    {
        $this->append(sprintf('RENAME TABLE %s TO %s ', $this->quote($old), $this->quote($new)));
        return $this;
    }
836722
public function replaceTable($oldTable, $newTable) {
		$this->where = $this->replaceTableInConditions($this->where, $oldTable, $newTable);
		$this->joins = $this->replaceTableInConditions($this->joins, $oldTable, $newTable);
		#using regex to replace table names not preceded by one of the following character
		if($this->groupBy)
			$this->groupBy[0] = preg_replace('/(?<![a-zA-Z0-9_])'.$oldTable.'\./', $newTable.'.', $this->groupBy[0]);
	}
1105726
public function rename($new, $old = null)
    {
        $this->arguments[] = 'rename';
        if ($old) {
            $this->arguments[] = $old;
        }
        $this->arguments[] = $new;
        return $this;
    }
568733
public function alterDbTable($model, $oldDbTableName, $newDbTableName)
    {
        if ($oldDbTableName === $newDbTableName) {
            return;
        }
        $this->renameTable($oldDbTableName, $newDbTableName);
    }
691175
protected function getTableMigrationNewTablesColumns(array $output, array $table, string $tableName, array $new, array $old): array
    {
        if (empty($table['columns'])) {
            return $output;
        }

        $array = new ArrayUtil();

        // Remove not used keys
        $array->unsetArrayKeys($new, 'COLUMN_KEY');
        $array->unsetArrayKeys($old, 'COLUMN_KEY');

        foreach ($table['columns'] as $columnName => $columnData) {
            if (!isset($old['tables'][$tableName]['columns'][$columnName])) {
                $output[] = $this->getColumnCreateAddNoUpdate($new, $tableName, $columnName);
            } else {
                if ($this->neq($new, $old, ['tables', $tableName, 'columns', $columnName])) {
                    $output[] = $this->getColumnUpdate($new, $tableName, $columnName);
                }
            }
        }

        return $output;
    }
725718
public function renameForeignKey($oldName, $newName)
    {
        if (!$this->hasForeignKey($oldName)) {
            throw SchemaException::tableForeignKeyDoesNotExist($this->getName(), $oldName);
        }

        if ($this->hasForeignKey($newName)) {
            throw SchemaException::tableForeignKeyAlreadyExists($this->getName(), $newName);
        }

        $this->foreignKeys[$oldName]->setName($newName);
        $this->foreignKeys[$newName] = $this->foreignKeys[$oldName];
        unset($this->foreignKeys[$oldName]);
    }
339733
public function renameColumn($oldName, $newName)
    {
        foreach ($this->rows as $row) {
            $row->renameColumn($oldName, $newName);

            $subTable = $row->getSubtable();
            if ($subTable) {
                $subTable->renameColumn($oldName, $newName);
            }
        }
        if (!is_null($this->summaryRow)) {
            $this->summaryRow->renameColumn($oldName, $newName);
        }
        if (!is_null($this->totalsRow)) {
            $this->totalsRow->renameColumn($oldName, $newName);
        }
    }
220086
public function renameTable($oldName, $newName)
    {
        if (!$this->hasTable($oldName)) {
            throw SchemaException::schemaTableDoesNotExist($this->getName(), $oldName);
        }

        if ($this->hasTable($newName)) {
            throw SchemaException::schemaTableAlreadyExists($this->getName(), $newName);
        }

        $this->tables[$oldName]->setName($newName);
        $this->tables[$newName] = $this->tables[$oldName];

        unset($this->tables[$oldName]);
    }
538381
public function isFieldExists($table, $field)
	{
		if (isset($this->tables[$table])) {
			$fields = $this->getFields($table);

			return $fields->where('name', $field)->count() > 0;
		}

		return false;
	}
811163
public static void rename(ObjectNode obj, String oldFieldName, String newFieldName) {
		if (obj != null && isNotBlank(oldFieldName) && isNotBlank(newFieldName)) {
			JsonNode node = remove(obj, oldFieldName);
			if (node != null) {
				obj.set(newFieldName, node);
			}
		}
	}
1138634
final public function renameTable($table, $to)
    {
        if ($this->adapter->getName() == 'mysql') {
            $command = 'RENAME';
        } else {
            $command = 'ALTER TABLE';
        }

        $sql = sprintf('%s %s TO %s', $command, $table, $to);

        return $this->executeSqlQuery($sql);
    }
796533
public function renameTable($oldTableName, $newTableName)
    {
        $table = $this->getTable($oldTableName);
        $table->_setName($newTableName);

        $this->dropTable($oldTableName);
        $this->_addTable($table);

        return $this;
    }
1145082
public static function rename($table, $new_name)
	{
		$table = new Table($table);

		// To indicate that the table needs to be renamed, we will run the
		// "rename" command on the table instance and pass the instance to
		// the execute method as calling a Closure isn't needed.
		$table->rename($new_name);

		return static::execute($table);
	}
266627
public function renameCheck($oldName, $newName)
    {
        if (!$this->hasCheck($oldName)) {
            throw SchemaException::tableCheckDoesNotExist($this->getName(), $oldName);
        }

        if ($this->hasCheck($newName)) {
            throw SchemaException::tableCheckAlreadyExists($this->getName(), $newName);
        }

        $this->checks[$oldName]->setName($newName);
        $this->checks[$newName] = $this->checks[$oldName];
        unset($this->checks[$oldName]);
    }
124597
public function renameColumn($oldName, $newName)
    {
        $this->getAdapter()->renameColumn($this->getName(), $oldName, $newName);

        return $this;
    }