CreateTelescopeEntriesTable::up()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 40

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 40
rs 9.28
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
use Illuminate\Support\Facades\Schema;
4
use Illuminate\Database\Schema\Blueprint;
5
use Illuminate\Database\Migrations\Migration;
6
7
class CreateTelescopeEntriesTable extends Migration
8
{
9
    /**
10
     * The database schema.
11
     *
12
     * @var Schema
13
     */
14
    protected $schema;
15
16
    /**
17
     * Create a new migration instance.
18
     *
19
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
20
     */
21
    public function __construct()
22
    {
23
        $this->schema = Schema::connection(
0 ignored issues
show
Documentation Bug introduced by
It seems like \Illuminate\Support\Faca....database.connection')) of type object<Illuminate\Database\Schema\Builder> is incompatible with the declared type object<Illuminate\Support\Facades\Schema> of property $schema.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
24
            \Illuminate\Support\Facades\Config::get('telescope.storage.database.connection')
25
        );
26
    }
27
28
    /**
29
     * Run the migrations.
30
     *
31
     * @return void
32
     */
33
    public function up()
34
    {
35
        $this->schema->create(
36
            'telescope_entries', function (Blueprint $table) {
37
                $table->bigIncrements('sequence');
38
                $table->uuid('uuid');
39
                $table->uuid('batch_id');
40
                $table->string('family_hash')->nullable()->index();
41
                $table->boolean('should_display_on_index')->default(true);
42
                $table->string('type', 20);
43
                $table->longText('content');
44
                $table->dateTime('created_at')->nullable();
45
46
                $table->unique('uuid');
47
                $table->index('batch_id');
48
                $table->index(['type', 'should_display_on_index']);
49
            }
50
        );
51
52
        $this->schema->create(
53
            'telescope_entries_tags', function (Blueprint $table) {
54
                $table->uuid('entry_uuid');
55
                $table->string('tag');
56
57
                $table->index(['entry_uuid', 'tag']);
58
                $table->index('tag');
59
60
                $table->foreign('entry_uuid')
61
                    ->references('uuid')
62
                    ->on('telescope_entries')
63
                    ->onDelete('cascade');
64
            }
65
        );
66
67
        $this->schema->create(
68
            'telescope_monitoring', function (Blueprint $table) {
69
                $table->string('tag');
70
            }
71
        );
72
    }
73
74
    /**
75
     * Reverse the migrations.
76
     *
77
     * @return void
78
     */
79
    public function down()
80
    {
81
        $this->schema->dropIfExists('telescope_entries_tags');
82
        $this->schema->dropIfExists('telescope_entries');
83
        $this->schema->dropIfExists('telescope_monitoring');
84
    }
85
}
86