recreate project
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Support;
|
||||
|
||||
use CodeIgniter\Test\CIUnitTestCase;
|
||||
use Config\Database;
|
||||
|
||||
class DBReset
|
||||
{
|
||||
protected static array $excludeTables = ['migrations'];
|
||||
|
||||
public static function resetDatabase(): void
|
||||
{
|
||||
$db = Database::connect();
|
||||
$db->disableForeignKeyChecks();
|
||||
|
||||
// Get all table names
|
||||
$tables = $db->listTables();
|
||||
|
||||
foreach ($tables as $table) {
|
||||
if (!in_array($table, self::$excludeTables)) {
|
||||
$db->table($table)->truncate();
|
||||
}
|
||||
}
|
||||
|
||||
$db->enableForeignKeyChecks();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user