CreatePrivRolesTable::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
use Illuminate\Support\Facades\Schema;
4
use Illuminate\Database\Schema\Blueprint;
5
use Illuminate\Database\Migrations\Migration;
6
7
class CreatePrivRolesTable extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        Schema::create('priv_roles', function (Blueprint $table) {
17
            $table->increments('id');
18
            $table->string('name')->unique();
19
            $table->unsignedTinyInteger('level')->default(0); // Visitor,Employee,Manager,Director
20
            $table->unsignedInteger('parent_id')->nullable();
21
            $table->text('childs')->nullable();
22
            $table->text('restrictions')->nullable();
23
            $table->timestamps();
24
25
            $table->foreign('parent_id')->references('id')->on('priv_roles')->onDelete('SET NULL');
26
        });
27
    }
28
29
    /**
30
     * Reverse the migrations.
31
     *
32
     * @return void
33
     */
34
    public function down()
35
    {
36
        Schema::disableForeignKeyConstraints();
37
38
        Schema::dropIfExists('priv_roles');
39
    }
40
}
41