Completed
Push — master ( 3d9eaa...7212f9 )
by Stephen
35:45
created

CreatePermissionUserTable::down()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
use Illuminate\Support\Facades\Schema;
4
use Illuminate\Database\Schema\Blueprint;
5
use Illuminate\Database\Migrations\Migration;
6
7
class CreatePermissionUserTable extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        Schema::create('permission_' . str_singular(config('laravel-acl.authTable')), function (Blueprint $table) {
17
            $table->increments('id');
18
            $table->integer('permission_id')->unsigned();
19
            $table->integer(str_singular(config('laravel-acl.authTable')) . '_id')->unsigned();
20
            $table->boolean('negated')->default(false);
21
            $table->timestamps();
22
23
            $table->index('permission_id');
24
            $table->index(str_singular(config('laravel-acl.authTable')) . '_id');
25
            $table->index('negated');
26
27
            $table->foreign('permission_id')->references('id')->on('permissions');
28
            $table->foreign(str_singular(config('laravel-acl.authTable')) . '_id')->references('id')->on(config('laravel-acl.authTable'));
29
        });
30
    }
31
32
    /**
33
     * Reverse the migrations.
34
     *
35
     * @return void
36
     */
37
    public function down()
38
    {
39
        Schema::table('permission_' . str_singular(config('laravel-acl.authTable')), function (Blueprint $table) {
40
            $table->dropForeign(['permission_id']);
41
            $table->dropForeign([str_singular(config('laravel-acl.authTable')) . '_id']);
42
        });
43
44
        Schema::dropIfExists('permission_' . str_singular(config('laravel-acl.authTable')));
45
    }
46
}
47