AddPermissionsTable20210717094547::down()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php
2
3
namespace Platine\Framework\Migration;
4
5
use Platine\Database\Schema\CreateTable;
6
use Platine\Framework\Migration\AbstractMigration;
7
8
class AddPermissionsTable20210717094547 extends AbstractMigration
9
{
10
    public function up(): void
11
    {
12
      //Action when migrate up
13
        $this->create('permissions', function (CreateTable $table) {
14
            $table->integer('id')
15
                  ->autoincrement()
16
                 ->primary();
17
            
18
            $table->string('code')
19
                 ->description('The permission code')
20
                 ->unique()
21
                 ->notNull();
22
            
23
            $table->string('description')
24
                 ->description('The permission description')
25
                 ->notNull();
26
            
27
            $table->integer('parent_id')
28
                  ->description('The parent permission');
29
            
30
            $table->timestamps();
31
            
32
            $table->foreign('parent_id')
33
                 ->references('permissions', 'id')
34
                 ->onDelete('CASCADE');
35
36
            $table->engine('INNODB');
37
        });
38
    }
39
40
    public function down(): void
41
    {
42
      //Action when migrate down
43
        $this->drop('permissions');
44
    }
45
}
46