| Conditions | 2 |
| Paths | 4 |
| Total Lines | 28 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 20 | public function migrateUp() |
||
| 21 | { |
||
| 22 | try { |
||
| 23 | $this->builder->table( |
||
| 24 | $this->table, |
||
| 25 | function ($table) { |
||
| 26 | $table->dropUnique('tracker_agents_name_unique'); |
||
| 27 | |||
| 28 | $table->string('name_hash', 65)->nullable(); |
||
| 29 | } |
||
| 30 | ); |
||
| 31 | |||
| 32 | Agent::all()->each(function ($agent) { |
||
| 33 | $agent->name_hash = hash('sha256', $agent->name); |
||
| 34 | |||
| 35 | $agent->save(); |
||
| 36 | }); |
||
| 37 | |||
| 38 | $this->builder->table( |
||
| 39 | $this->table, |
||
| 40 | function ($table) { |
||
| 41 | $table->unique('name_hash'); |
||
| 42 | } |
||
| 43 | ); |
||
| 44 | } catch (\Exception $e) { |
||
| 45 | dd($e->getMessage()); |
||
| 46 | } |
||
| 47 | } |
||
| 48 | |||
| 71 |