Skip to content

Commit eea52a1

Browse files
committed
Update the db reset to include all tables not just the state.
1 parent a82ebf8 commit eea52a1

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/Libs/Database/PDO/PDOAdapter.php

+12-3
Original file line numberDiff line numberDiff line change
@@ -609,15 +609,24 @@ public function maintenance(array $opts = []): mixed
609609

610610
/**
611611
* @inheritdoc
612+
* @noinspection SqlWithoutWhere
612613
*/
613614
public function reset(): bool
614615
{
615-
$this->pdo->exec('DELETE FROM `state` WHERE `id` > 0');
616+
$this->pdo->beginTransaction();
616617

617-
if ('sqlite' === $this->pdo->getAttribute(PDO::ATTR_DRIVER_NAME)) {
618-
$this->pdo->exec('DELETE FROM sqlite_sequence WHERE name = "state"');
618+
$tables = $this->pdo->query(
619+
'SELECT name FROM sqlite_master WHERE "type" = "table" AND "name" NOT LIKE "sqlite_%"'
620+
);
621+
622+
foreach ($tables->fetchAll(PDO::FETCH_COLUMN) as $table) {
623+
$this->pdo->exec('DELETE FROM "' . $table . '"');
624+
$this->pdo->exec('DELETE FROM sqlite_sequence WHERE "name" = "' . $table . '"');
619625
}
620626

627+
$this->pdo->commit();
628+
$this->pdo->exec('VACUUM');
629+
621630
return true;
622631
}
623632

0 commit comments

Comments
 (0)