From f1266ab5d65bb01ba91908c6a2e0df6348235c5c Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 1 Oct 2025 11:24:20 +0100 Subject: [PATCH] Check if telescope tables already exist --- ..._100000_create_telescope_entries_table.php | 62 ++++++++++--------- 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/database/migrations/2018_08_08_100000_create_telescope_entries_table.php b/database/migrations/2018_08_08_100000_create_telescope_entries_table.php index 700a83f095..91b753b6a7 100644 --- a/database/migrations/2018_08_08_100000_create_telescope_entries_table.php +++ b/database/migrations/2018_08_08_100000_create_telescope_entries_table.php @@ -21,39 +21,45 @@ return new class extends Migration { $schema = Schema::connection($this->getConnection()); - $schema->create('telescope_entries', function (Blueprint $table) { - $table->bigIncrements('sequence'); - $table->uuid('uuid'); - $table->uuid('batch_id'); - $table->string('family_hash')->nullable(); - $table->boolean('should_display_on_index')->default(true); - $table->string('type', 20); - $table->longText('content'); - $table->dateTime('created_at')->nullable(); + if (! Schema::hasTable('telescope_entries') ) { + $schema->create('telescope_entries', function (Blueprint $table) { + $table->bigIncrements('sequence'); + $table->uuid('uuid'); + $table->uuid('batch_id'); + $table->string('family_hash')->nullable(); + $table->boolean('should_display_on_index')->default(true); + $table->string('type', 20); + $table->longText('content'); + $table->dateTime('created_at')->nullable(); - $table->unique('uuid'); - $table->index('batch_id'); - $table->index('family_hash'); - $table->index('created_at'); - $table->index(['type', 'should_display_on_index']); - }); + $table->unique('uuid'); + $table->index('batch_id'); + $table->index('family_hash'); + $table->index('created_at'); + $table->index(['type', 'should_display_on_index']); + }); + } - $schema->create('telescope_entries_tags', function (Blueprint $table) { - $table->uuid('entry_uuid'); - $table->string('tag'); + if (! Schema::hasTable('telescope_entries_tags') ) { + $schema->create('telescope_entries_tags', function (Blueprint $table) { + $table->uuid('entry_uuid'); + $table->string('tag'); - $table->primary(['entry_uuid', 'tag']); - $table->index('tag'); + $table->primary(['entry_uuid', 'tag']); + $table->index('tag'); - $table->foreign('entry_uuid') - ->references('uuid') - ->on('telescope_entries') - ->onDelete('cascade'); - }); + $table->foreign('entry_uuid') + ->references('uuid') + ->on('telescope_entries') + ->onDelete('cascade'); + }); + } - $schema->create('telescope_monitoring', function (Blueprint $table) { - $table->string('tag')->primary(); - }); + if (! Schema::hasTable('telescope_monitoring') ) { + $schema->create('telescope_monitoring', function (Blueprint $table) { + $table->string('tag')->primary(); + }); + } } /**