1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2024-12-22 13:12:41 +00:00

Improve MySQL test performance

This commit is contained in:
J. King 2021-12-30 18:22:50 -05:00
parent 3c884f521b
commit b660508009

View file

@ -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");
} }
} }