Skip to content

Commit 22c5537

Browse files
ikidnapmyselfclaude
andcommitted
fix: add Telescope migration and schedule prune (30-day retention)
The telescope_entries tables were never created, so every request failed its insert and dumped a stack trace into the log. Publishes the Telescope migration and schedules telescope:prune daily, keeping 30 days of history. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 1037d4e commit 22c5537

2 files changed

Lines changed: 72 additions & 1 deletion

File tree

app/Console/Kernel.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ class Kernel extends ConsoleKernel
2424
*/
2525
protected function schedule(Schedule $schedule)
2626
{
27-
// $schedule->command('inspire')->hourly();
27+
// Keep a generous Telescope history (30 days), pruning only older entries.
28+
$schedule->command('telescope:prune --hours=720')->daily();
2829
}
2930

3031
/**
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Get the migration connection name.
11+
*/
12+
public function getConnection(): ?string
13+
{
14+
return config('telescope.storage.database.connection');
15+
}
16+
17+
/**
18+
* Run the migrations.
19+
*/
20+
public function up(): void
21+
{
22+
$schema = Schema::connection($this->getConnection());
23+
24+
$schema->create('telescope_entries', function (Blueprint $table) {
25+
$table->bigIncrements('sequence');
26+
$table->uuid('uuid');
27+
$table->uuid('batch_id');
28+
$table->string('family_hash')->nullable();
29+
$table->boolean('should_display_on_index')->default(true);
30+
$table->string('type', 20);
31+
$table->longText('content');
32+
$table->dateTime('created_at')->nullable();
33+
34+
$table->unique('uuid');
35+
$table->index('batch_id');
36+
$table->index('family_hash');
37+
$table->index('created_at');
38+
$table->index(['type', 'should_display_on_index']);
39+
});
40+
41+
$schema->create('telescope_entries_tags', function (Blueprint $table) {
42+
$table->uuid('entry_uuid');
43+
$table->string('tag');
44+
45+
$table->primary(['entry_uuid', 'tag']);
46+
$table->index('tag');
47+
48+
$table->foreign('entry_uuid')
49+
->references('uuid')
50+
->on('telescope_entries')
51+
->cascadeOnDelete();
52+
});
53+
54+
$schema->create('telescope_monitoring', function (Blueprint $table) {
55+
$table->string('tag')->primary();
56+
});
57+
}
58+
59+
/**
60+
* Reverse the migrations.
61+
*/
62+
public function down(): void
63+
{
64+
$schema = Schema::connection($this->getConnection());
65+
66+
$schema->dropIfExists('telescope_entries_tags');
67+
$schema->dropIfExists('telescope_entries');
68+
$schema->dropIfExists('telescope_monitoring');
69+
}
70+
};

0 commit comments

Comments
 (0)