Skip to content

Commit

Permalink
Revert "[5.x] Enhance Telescope Clear Method (#1507)" (#1510)
Browse files Browse the repository at this point in the history
This reverts commit c3a794a.
  • Loading branch information
taylorotwell committed Aug 26, 2024
1 parent 5c08c9b commit daaf95d
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions src/Storage/DatabaseEntriesRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
namespace Laravel\Telescope\Storage;

use DateTimeInterface;
use Illuminate\Database\QueryException;
use Illuminate\Database\UniqueConstraintViolationException;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Laravel\Telescope\Contracts\ClearableRepository;
use Laravel\Telescope\Contracts\EntriesRepository as Contract;
use Laravel\Telescope\Contracts\PrunableRepository;
Expand Down Expand Up @@ -380,22 +378,13 @@ public function prune(DateTimeInterface $before, $keepExceptions)
*/
public function clear()
{
try {
Schema::disableForeignKeyConstraints();

$this->table('telescope_entries')->truncate();
$this->table('telescope_monitoring')->truncate();
} catch (QueryException) {
do {
$deleted = $this->table('telescope_entries')->take($this->chunkSize)->delete();
} while ($deleted !== 0);

do {
$deleted = $this->table('telescope_monitoring')->take($this->chunkSize)->delete();
} while ($deleted !== 0);
} finally {
Schema::enableForeignKeyConstraints();
}
do {
$deleted = $this->table('telescope_entries')->take($this->chunkSize)->delete();
} while ($deleted !== 0);

do {
$deleted = $this->table('telescope_monitoring')->take($this->chunkSize)->delete();
} while ($deleted !== 0);
}

/**
Expand Down

0 comments on commit daaf95d

Please sign in to comment.