From 0d6618e87cc4cbd3b05a3bd8c934a202b98ab6a6 Mon Sep 17 00:00:00 2001 From: Roardom Date: Sun, 19 May 2024 03:45:15 +0000 Subject: [PATCH] fix: use query builder instead of eloquent --- .../migrations/2022_11_23_024350_update_history_table.php | 6 +++--- .../migrations/2022_11_23_195306_update_peers_table.php | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/database/migrations/2022_11_23_024350_update_history_table.php b/database/migrations/2022_11_23_024350_update_history_table.php index 65ad6c15bd..7985236179 100644 --- a/database/migrations/2022_11_23_024350_update_history_table.php +++ b/database/migrations/2022_11_23_024350_update_history_table.php @@ -48,9 +48,9 @@ public function up(): void 'actual_uploaded' => $records->sum('actual_uploaded'), ]); - foreach ($records->where('id', '!=', $merged->id) as $record) { - $record->delete(); - } + DB::table('history') + ->whereIn('id', $records->where('id', '!=', $merged->id)->pluck('id')) + ->delete(); } Schema::table('history', function (Blueprint $table): void { diff --git a/database/migrations/2022_11_23_195306_update_peers_table.php b/database/migrations/2022_11_23_195306_update_peers_table.php index 9752838aa5..70300d79af 100644 --- a/database/migrations/2022_11_23_195306_update_peers_table.php +++ b/database/migrations/2022_11_23_195306_update_peers_table.php @@ -42,9 +42,9 @@ public function up(): void $first = $records->first(); - foreach ($records->where('id', '!=', $first->id) as $record) { - $record->delete(); - } + DB::table('peers') + ->whereIn('id', $records->where('id', '!=', $first->id)->pluck('id')) + ->delete(); } Schema::table('peers', function (Blueprint $table): void {