From d0dc5e5c5daccd3e8e801c5d2eac1aab0d300ae8 Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Thu, 8 Sep 2022 12:26:14 +0100 Subject: [PATCH] Added a little protection to migration query Just to be sure the query is filtered as expected to only affect shelf-based images. --- .../2022_09_02_082910_fix_shelf_cover_image_types.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/database/migrations/2022_09_02_082910_fix_shelf_cover_image_types.php b/database/migrations/2022_09_02_082910_fix_shelf_cover_image_types.php index 837bdfe24..a9a413607 100644 --- a/database/migrations/2022_09_02_082910_fix_shelf_cover_image_types.php +++ b/database/migrations/2022_09_02_082910_fix_shelf_cover_image_types.php @@ -22,10 +22,12 @@ class FixShelfCoverImageTypes extends Migration ->pluck('image_id') ->values()->all(); - DB::table('images') - ->where('type', '=', 'cover_book') - ->whereIn('id', $shelfImageIds) - ->update(['type' => 'cover_bookshelf']); + if (count($shelfImageIds) > 0) { + DB::table('images') + ->where('type', '=', 'cover_book') + ->whereIn('id', $shelfImageIds) + ->update(['type' => 'cover_bookshelf']); + } } /**