CreateStorageTables::down()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 10
rs 9.4285
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
3
use Illuminate\Database\Migrations\Migration;
4
use \jlourenco\base\Database\Blueprint;
5
6
class CreateStorageTables extends Migration
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
7
{
8
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
17
        Schema::create('FileGroup', function (Blueprint $table) {
18
            $table->increments('id');
19
            $table->string('name', 150);
20
            $table->string('description', 250);
21
        });
22
23
        Schema::create('File', function (Blueprint $table) {
24
            $table->increments('id');
25
            $table->string('name', 150);
26
            $table->string('stored_name', 150);
27
            $table->string('extension', 50);
28
            $table->text('description')->nullable();
29
30
            $table->timestamps();
31
            $table->softDeletes();
32
            $table->creation();
33
        });
34
35
        Schema::create('File_FileGroup', function (Blueprint $table) {
36
            $table->increments('id');
37
            $table->integer('file')->unsigned();
38
            $table->integer('filegroup')->unsigned();
39
40
            $table->foreign('file')->references('id')->on('File');
41
            $table->foreign('filegroup')->references('id')->on('FileGroup');
42
        });
43
44
        Schema::create('File_Entity', function (Blueprint $table) {
45
            $table->increments('id');
46
            $table->integer('file')->unsigned();
47
48
            $table->morphs("entity");
49
            $table->timestamps();
50
            $table->softDeletes();
51
            $table->creation();
52
53
            $table->foreign('file')->references('id')->on('File');
54
        });
55
56
    }
57
58
    /**
59
     * Reverse the migrations.
60
     *
61
     * @return void
62
     */
63
    public function down()
64
    {
65
66
        DB::statement('SET FOREIGN_KEY_CHECKS = 0');
67
        Schema::drop('File_Entity');
68
        Schema::drop('File_FileGroup');
69
        Schema::drop('File');
70
        Schema::drop('FileGroup');
71
        DB::statement('SET FOREIGN_KEY_CHECKS = 1');
72
    }
73
74
}
75