Passed
Push — master ( c36ed8...8867a0 )
by Quentin
13:25 queued 05:48
created

CreateFilesTables::up()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 18
nc 1
nop 0
dl 0
loc 22
rs 9.6666
c 0
b 0
f 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 CreateFilesTables extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        Schema::create('files', function (Blueprint $table) {
17
            $table->increments('id')->unsigned();
18
            $table->timestamps();
19
            $table->softDeletes();
20
            $table->string('uuid');
21
            $table->string('filename')->nullable();
22
            $table->integer('size')->unsigned();
23
        });
24
25
        Schema::create('fileables', function (Blueprint $table) {
26
            $table->increments('id');
27
            $table->timestamps();
28
            $table->softDeletes();
29
            $table->integer('file_id')->unsigned();
30
            $table->foreign('file_id', 'fk_files_file_id')->references('id')->on('files')->onDelete('cascade')->onUpdate('cascade');
31
            $table->integer('fileable_id')->nullable()->unsigned();
32
            $table->string('fileable_type')->nullable();
33
            $table->string('role')->nullable();
34
            $table->string('locale', 6)->index();
35
            $table->index(['fileable_type', 'fileable_id']);
36
        });
37
    }
38
39
    /**
40
     * Reverse the migrations.
41
     *
42
     * @return void
43
     */
44
    public function down()
45
    {
46
        Schema::dropIfExists('fileables');
47
        Schema::dropIfExists('files');
48
    }
49
}
50