Skip to content

Commit

Permalink
#2210 Fixed migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Wotuu committed Feb 23, 2024
1 parent 75ac7f7 commit f5ffc4a
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use App\Models\AffixGroup\AffixGroupEaseTierPull;
use App\Service\AffixGroup\AffixGroupEaseTierServiceInterface;
use Illuminate\Contracts\Container\BindingResolutionException;
use Illuminate\Database\Migrations\Migration;
Expand All @@ -23,12 +24,19 @@ public function up()

foreach ($rows as $row) {
$row = (array)$row;
DB::update('

$affixGroup = $affixGroupEaseTierService->getAffixGroupByString($row['current_affixes']);
if ($affixGroup === null) {
// Delete it through Eloquent so that it cleans up the relationships as well
AffixGroupEaseTierPull::findOrFail($row['id'])->delete();
} else {
DB::update('
UPDATE affix_group_ease_tier_pulls SET affix_group_id = :affixGroupId WHERE id = :id
', [
'affixGroupId' => $affixGroupEaseTierService->getAffixGroupByString($row['current_affixes'])->id,
'id' => $row['id'],
]);
'affixGroupId' => $affixGroup->id,
'id' => $row['id'],
]);
}
}
}

Expand Down

0 comments on commit f5ffc4a

Please sign in to comment.