Browse Source

Improve MySQL test performance

dbtest
J. King 2 years ago
parent
commit
b660508009
  1. 7
      tests/lib/DatabaseDrivers/MySQL.php

7
tests/lib/DatabaseDrivers/MySQL.php

@ -59,14 +59,13 @@ trait MySQL {
if ($table === "arsse_meta") { if ($table === "arsse_meta") {
$db->query("DELETE FROM $table where `key` <> 'schema_version'"); $db->query("DELETE FROM $table where `key` <> 'schema_version'");
} else { } else {
$db->query("DELETE FROM $table"); $db->query("TRUNCATE TABLE $table");
} }
$db->query("ALTER TABLE $table auto_increment = 1");
} }
$db->query("SET FOREIGN_KEY_CHECKS=1");
foreach ($afterStatements as $st) { foreach ($afterStatements as $st) {
$db->query($st); $db->query($st);
} }
$db->query("SET FOREIGN_KEY_CHECKS=1");
} }
public static function dbRaze($db, array $afterStatements = []): void { public static function dbRaze($db, array $afterStatements = []): void {
@ -79,9 +78,9 @@ trait MySQL {
foreach (self::dbTableList($db) as $table) { foreach (self::dbTableList($db) as $table) {
$db->query("DROP TABLE IF EXISTS $table"); $db->query("DROP TABLE IF EXISTS $table");
} }
$db->query("SET FOREIGN_KEY_CHECKS=1");
foreach ($afterStatements as $st) { foreach ($afterStatements as $st) {
$db->query($st); $db->query($st);
} }
$db->query("SET FOREIGN_KEY_CHECKS=1");
} }
} }

Loading…
Cancel
Save