Skip to content

Commit f1266ab

Browse files
committed
Check if telescope tables already exist
1 parent 664e398 commit f1266ab

File tree

1 file changed

+34
-28
lines changed

1 file changed

+34
-28
lines changed

database/migrations/2018_08_08_100000_create_telescope_entries_table.php

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,39 +21,45 @@ public function up(): void
2121
{
2222
$schema = Schema::connection($this->getConnection());
2323

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();
24+
if (! Schema::hasTable('telescope_entries') ) {
25+
$schema->create('telescope_entries', function (Blueprint $table) {
26+
$table->bigIncrements('sequence');
27+
$table->uuid('uuid');
28+
$table->uuid('batch_id');
29+
$table->string('family_hash')->nullable();
30+
$table->boolean('should_display_on_index')->default(true);
31+
$table->string('type', 20);
32+
$table->longText('content');
33+
$table->dateTime('created_at')->nullable();
3334

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-
});
35+
$table->unique('uuid');
36+
$table->index('batch_id');
37+
$table->index('family_hash');
38+
$table->index('created_at');
39+
$table->index(['type', 'should_display_on_index']);
40+
});
41+
}
4042

41-
$schema->create('telescope_entries_tags', function (Blueprint $table) {
42-
$table->uuid('entry_uuid');
43-
$table->string('tag');
43+
if (! Schema::hasTable('telescope_entries_tags') ) {
44+
$schema->create('telescope_entries_tags', function (Blueprint $table) {
45+
$table->uuid('entry_uuid');
46+
$table->string('tag');
4447

45-
$table->primary(['entry_uuid', 'tag']);
46-
$table->index('tag');
48+
$table->primary(['entry_uuid', 'tag']);
49+
$table->index('tag');
4750

48-
$table->foreign('entry_uuid')
49-
->references('uuid')
50-
->on('telescope_entries')
51-
->onDelete('cascade');
52-
});
51+
$table->foreign('entry_uuid')
52+
->references('uuid')
53+
->on('telescope_entries')
54+
->onDelete('cascade');
55+
});
56+
}
5357

54-
$schema->create('telescope_monitoring', function (Blueprint $table) {
55-
$table->string('tag')->primary();
56-
});
58+
if (! Schema::hasTable('telescope_monitoring') ) {
59+
$schema->create('telescope_monitoring', function (Blueprint $table) {
60+
$table->string('tag')->primary();
61+
});
62+
}
5763
}
5864

5965
/**

0 commit comments

Comments
 (0)