CreateScavengerScrapsTable::down()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 5
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
use Illuminate\Database\Migrations\Migration;
6
use Illuminate\Database\Schema\Blueprint;
7
use Illuminate\Support\Facades\Schema;
8
use ReliqArts\Scavenger\Service\ConfigProvider;
9
10
class CreateScavengerScrapsTable extends Migration
11
{
12
    /**
13
     * Run the migrations.
14
     */
15
    public function up(): void
16
    {
17
        $table = ConfigProvider::getScrapsTable();
18
        if (!Schema::hasTable($table)) {
19
            Schema::create($table, static function (Blueprint $table) {
20
                $table->increments('id');
21
                $table->string('hash', 128)->unique(); // a hash
22
                $table->string('title')->nullable();
23
                $table->string('model', 256);
24
                $table->string('related', 256)->nullable();
25
                $table->text('data');
26
                $table->string('source', 400);
27
                $table->timestamps();
28
            });
29
        }
30
    }
31
32
    /**
33
     * Reverse the migrations.
34
     */
35
    public function down(): void
36
    {
37
        $table = ConfigProvider::getScrapsTable();
38
39
        Schema::dropIfExists($table);
40
    }
41
}
42