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 |
|
|
|
|
20
|
|
|
*/ |
21
|
|
|
public function __construct() |
22
|
|
|
{ |
23
|
|
|
$this->schema = Schema::connection( |
|
|
|
|
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
|
|
|
|
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.