From 6e09173f9bb6486ee89585d92d18b8b8969aa783 Mon Sep 17 00:00:00 2001 From: Holger Schletz Date: Sun, 6 Dec 2020 20:22:49 +0100 Subject: [PATCH] Added table renaming. --- src/Database/AbstractDatabase.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Database/AbstractDatabase.php b/src/Database/AbstractDatabase.php index 9ea92a1..3442182 100644 --- a/src/Database/AbstractDatabase.php +++ b/src/Database/AbstractDatabase.php @@ -898,6 +898,21 @@ protected function _getTablePkDeclaration(array $primaryKey, $autoIncrement) return ",\nPRIMARY KEY (" . implode(', ', $primaryKey) . ')'; } + /** + * Rename a table. + */ + public function renameTable(string $oldName, string $newName): void + { + $this->exec( + sprintf( + 'ALTER TABLE %s RENAME TO %s', + $this->prepareIdentifier($oldName), + $this->prepareIdentifier($newName) + ) + ); + $this->clearCache($oldName); + } + /** * Drop a table *