Total Complexity | 2 |
Total Lines | 27 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
8 | class AddRoleUsersTable20210717100434 extends AbstractMigration |
||
9 | { |
||
10 | public function up(): void |
||
11 | { |
||
12 | //Action when migrate up |
||
13 | $this->create('roles_users', function (CreateTable $table) { |
||
14 | $table->integer('user_id'); |
||
15 | $table->integer('role_id'); |
||
16 | |||
17 | $table->primary(['user_id', 'role_id']); |
||
18 | |||
19 | $table->foreign('user_id') |
||
20 | ->references('users', '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 |
||
35 | } |
||
36 | } |
||
37 |