AddPermissionRolesTable20210717094822::up()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 11
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 18
rs 9.9
1
<?php
2
3
namespace Platine\Framework\Migration;
4
5
use Platine\Database\Schema\CreateTable;
6
use Platine\Framework\Migration\AbstractMigration;
7
8
class AddPermissionRolesTable20210717094822 extends AbstractMigration
9
{
10
    public function up(): void
11
    {
12
      //Action when migrate up
13
        $this->create('permissions_roles', function (CreateTable $table) {
14
            $table->integer('permission_id');
15
            $table->integer('role_id');
16
17
            $table->primary(['permission_id', 'role_id']);
18
19
            $table->foreign('permission_id')
20
                 ->references('permissions', 'id')
21
                 ->onDelete('CASCADE');
22
23
            $table->foreign('role_id')
24
                  ->references('roles', 'id')
25
                  ->onDelete('CASCADE');
26
27
            $table->engine('INNODB');
28
        });
29
    }
30
31
    public function down(): void
32
    {
33
      //Action when migrate down
34
        $this->drop('permissions_roles');
35
    }
36
}
37