| Total Complexity | 4 |
| Total Lines | 29 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 5 | class ModifyRolesAndPermissionsTableOptimizeIndexes extends BaseMigration |
||
| 6 | { |
||
| 7 | public function up() |
||
| 11 | } |
||
| 12 | |||
| 13 | public function down() |
||
| 14 | { |
||
| 15 | $this->revertIndexes($this->user_roles, 'user_id', 'role_id'); |
||
| 16 | $this->revertIndexes($this->role_permissions, 'role_id', 'permission_id'); |
||
| 17 | } |
||
| 18 | |||
| 19 | protected function optimizeIndexes(string $table, string $first_key, string $second_key) |
||
| 20 | { |
||
| 21 | $this->table($table, function (Blueprint $table) use ($first_key, $second_key) { |
||
| 22 | $table->dropPrimary([$first_key, $second_key]); |
||
| 23 | |||
| 24 | $table->index($first_key); |
||
| 25 | }); |
||
| 26 | } |
||
| 27 | |||
| 28 | protected function revertIndexes(string $table, string $first_key, string $second_key) |
||
| 34 | }); |
||
| 35 | } |
||
| 36 | } |
||
| 37 |