Test Failed
Push — develop ( ebbd0c...8a31ce )
by nguereza
03:10
created

AddPermissionRolesTable20210717094822   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 28
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 18 1
A down() 0 4 1
1
<?php
2
namespace Platine\Framework\Migration;
3
4
use Platine\Database\Schema\CreateTable;
5
use Platine\Framework\Migration\AbstractMigration;
6
7
class AddPermissionRolesTable20210717094822 extends AbstractMigration
8
{
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
}