create_hasin_test_table.php$0 ➔ up()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 78
Code Lines 64

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
eloc 64
nc 1
nop 0
dl 0
loc 78
rs 8.7853
c 1
b 1
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
use Illuminate\Database\Migrations\Migration;
4
use Illuminate\Database\Schema\Blueprint;
5
use Illuminate\Support\Facades\Schema;
6
7
return new class () extends Migration {
8
    /**
9
     * Run the migrations.
10
     *
11
     * @return void
12
     */
13
    public function up()
14
    {
15
        Schema::create('histories', function (Blueprint $table) {
16
            $table->id();
17
            $table->bigInteger('user_id')->default(0);
18
            $table->string('content');
19
            $table->timestamps();
20
        });
21
        Schema::create('comments', function (Blueprint $table) {
22
            $table->id();
23
            $table->morphs('commentable');
24
            $table->string('content');
25
            $table->tinyInteger('status')->default(0);
26
            $table->timestamps();
27
        });
28
        Schema::create('countries', function (Blueprint $table) {
29
            $table->id();
30
            $table->string('name')->default('');
31
            $table->timestamps();
32
        });
33
        Schema::create('images', function (Blueprint $table) {
34
            $table->id();
35
            $table->string('url')->default('');
36
            $table->morphs('imageable');
37
            $table->timestamps();
38
        });
39
        Schema::create('phones', function (Blueprint $table) {
40
            $table->id();
41
            $table->bigInteger('user_id')->default(0);
42
            $table->string('phone_number')->default('');
43
            $table->timestamps();
44
        });
45
        Schema::create('roles', function (Blueprint $table) {
46
            $table->id();
47
            $table->string('name');
48
            $table->timestamps();
49
        });
50
        Schema::create('role_user', function (Blueprint $table) {
51
            $table->id();
52
            $table->bigInteger('user_id')->default(0);
53
            $table->bigInteger('role_id')->default(0);
54
            $table->timestamps();
55
        });
56
        Schema::create('suppliers', function (Blueprint $table) {
57
            $table->id();
58
            $table->string('name')->default('');
59
            $table->timestamps();
60
        });
61
        Schema::create('tags', function (Blueprint $table) {
62
            $table->id();
63
            $table->string('name')->default('');
64
            $table->timestamps();
65
        });
66
        Schema::create('taggables', function (Blueprint $table) {
67
            $table->id();
68
            $table->bigInteger('tag_id')->default(0);
69
            $table->morphs('taggable');
70
            $table->timestamps();
71
        });
72
        Schema::create('users', function (Blueprint $table) {
73
            $table->id();
74
            $table->string('username')->default('');
75
            $table->tinyInteger('age')->default(0);
76
            $table->bigInteger('country_id')->default(0);
77
            $table->bigInteger('supplier_id')->default(0);
78
            $table->timestamps();
79
        });
80
        Schema::create('videos', function (Blueprint $table) {
81
            $table->id();
82
            $table->string('name')->default('');
83
            $table->timestamps();
84
        });
85
        Schema::create('posts', function (Blueprint $table) {
86
            $table->id();
87
            $table->bigInteger('user_id')->default(0);
88
            $table->string('title')->default('');
89
            $table->integer('votes')->default(0);
90
            $table->timestamps();
91
        });
92
    }
93
94
    /**
95
     * Reverse the migrations.
96
     *
97
     * @return void
98
     */
99
    public function down()
100
    {
101
        Schema::dropIfExists('histories');
102
        Schema::dropIfExists('comments');
103
        Schema::dropIfExists('countries');
104
        Schema::dropIfExists('images');
105
        Schema::dropIfExists('phones');
106
        Schema::dropIfExists('roles');
107
        Schema::dropIfExists('role_user');
108
        Schema::dropIfExists('suppliers');
109
        Schema::dropIfExists('tags');
110
        Schema::dropIfExists('taggables');
111
        Schema::dropIfExists('users');
112
        Schema::dropIfExists('videos');
113
        Schema::dropIfExists('posts');
114
    }
115
};
116