FIX Truncate table to clear table

This commit is contained in:
Steve Boyd 2024-07-19 21:13:34 +12:00
parent b6e347ef3d
commit 539d4645b9

View File

@ -566,16 +566,6 @@ class MySQLDatabase extends Database implements TransactionManager
*/ */
public function clearTable($table) public function clearTable($table)
{ {
$this->query("DELETE FROM \"$table\""); $this->query("TRUNCATE TABLE \"$table\"");
// Check if resetting the auto-increment is needed
$autoIncrement = $this->preparedQuery(
'SELECT "AUTO_INCREMENT" FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = ? AND TABLE_NAME = ?',
[ $this->getSelectedDatabase(), $table]
)->value();
if ($autoIncrement > 1) {
$this->query("ALTER TABLE \"$table\" AUTO_INCREMENT = 1");
}
} }
} }