function DatabaseSchema_mysql::renameTable

Overrides DatabaseSchema::renameTable

File

includes/database/mysql/schema.inc, line 315

Class

DatabaseSchema_mysql

Code

public function renameTable($table, $new_name) {
    if (!$this->tableExists($table)) {
        throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot rename @table to @table_new: table @table doesn't exist.", array(
            '@table' => $table,
            '@table_new' => $new_name,
        )));
    }
    if ($this->tableExists($new_name)) {
        throw new DatabaseSchemaObjectExistsException(t("Cannot rename @table to @table_new: table @table_new already exists.", array(
            '@table' => $table,
            '@table_new' => $new_name,
        )));
    }
    $info = $this->getPrefixInfo($new_name);
    return $this->connection
        ->query('ALTER TABLE {' . $table . '} RENAME TO `' . $info['table'] . '`');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.