Merge pull request #11309 from creative-commoners/pulls/5.2/clear-table

FIX Truncate table to clear table
This commit is contained in:
Guy Sartorelli 2024-07-22 09:03:07 +12:00 committed by GitHub
commit 4693e3f378
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -566,16 +566,6 @@ class MySQLDatabase extends Database implements TransactionManager
*/
public function clearTable($table)
{
$this->query("DELETE FROM \"$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");
}
$this->query("TRUNCATE TABLE \"$table\"");
}
}