UptimeSetupTables::up()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 21
rs 9.584
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
use Illuminate\Database\Migrations\Migration;
4
use Illuminate\Database\Schema\Blueprint;
5
use Illuminate\Support\Facades\Schema;
6
7
class UptimeSetupTables extends Migration
8
{
9
    public function up()
10
    {
11
        Schema::create(config('uptime.endpoints_table'), function (Blueprint $table) {
12
            $table->increments('id')->unsigned();
13
            $table->text('uri');
14
            $table->integer('frequency');
15
            $table->timestamps();
16
        });
17
18
        Schema::create(config('uptime.statuses_table'), function (Blueprint $table) {
19
            $table->increments('id')->unsigned();
20
            $table->integer('endpoint_id')->unsigned();
21
            $table->integer('status_code');
22
            $table->timestamps();
23
24
            $table->foreign('endpoint_id')
25
                ->references('id')
26
                ->on(config('uptime.endpoints_table'))
27
                ->onDelete('cascade');
28
        });
29
    }
30
31
    /**
32
     * Reverse the migrations.
33
     *
34
     * @return void
35
     */
36
    public function down()
37
    {
38
        Schema::drop(config('uptime.endpoints_table'));
39
        Schema::drop(config('uptime.statuses_table'));
40
    }
41
}
42