- public function renameTable($oldTableName, $newTableName, $schemaName = null)
- {
- if (!$this->isTableExists($oldTableName, $schemaName)) {
- throw new \Zend_Db_Exception(sprintf('Table "%s" is not exists', $oldTableName));
- }
- if ($this->isTableExists($newTableName, $schemaName)) {
- throw new \Zend_Db_Exception(sprintf('Table "%s" already exists', $newTableName));
- }
-
- $oldTable = $this->_getTableName($oldTableName, $schemaName);
- $newTable = $this->_getTableName($newTableName, $schemaName);
-
- $query = sprintf('ALTER TABLE %s RENAME TO %s', $oldTable, $newTable);
- $this->query($query);
-
- $this->resetDdlCache($oldTableName, $schemaName);
-
- return true;
- }