Total Complexity | 5 |
Total Lines | 47 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | class CreatePrivUserRoleTable extends Migration |
||
10 | { |
||
11 | /** |
||
12 | * Run the migrations. |
||
13 | * |
||
14 | * @return void |
||
15 | */ |
||
16 | public function up() |
||
17 | { |
||
18 | $config = Manager::getAuthorizableMigration(); |
||
19 | |||
20 | Schema::create('priv_auth_role', function (Blueprint $table) use ($config) { |
||
21 | // Depend on Authorizable table structure |
||
22 | // package provides support for tree types |
||
23 | // of primaryKey: integer, string & uuid. |
||
24 | // |
||
25 | if ($config['type'] == 'int') { |
||
26 | $table->unsignedInteger('auth_id'); |
||
27 | |||
28 | } elseif ($config['type'] == 'string') { |
||
29 | $table->string('auth_id'); |
||
30 | |||
31 | } elseif ($config['type'] == 'uuid') { |
||
32 | $table->uuid('auth_id'); |
||
33 | } |
||
34 | $table->unsignedInteger('role_id'); |
||
35 | |||
36 | $table->foreign('auth_id') |
||
37 | ->references($config['key'])->on($config['table']) |
||
38 | ->onDelete('CASCADE'); |
||
39 | |||
40 | $table->foreign('role_id') |
||
41 | ->references('id')->on('priv_roles') |
||
42 | ->onDelete('CASCADE'); |
||
43 | }); |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * Reverse the migrations. |
||
48 | * |
||
49 | * @return void |
||
50 | */ |
||
51 | public function down() |
||
56 | } |
||
57 | } |
||
58 |