From: Dan Brown Date: Thu, 8 Sep 2022 11:26:14 +0000 (+0100) Subject: Added a little protection to migration query X-Git-Tag: v22.09~1^2 X-Git-Url: http://source.bookstackapp.com/bookstack/commitdiff_plain/d0dc5e5c5daccd3e8e801c5d2eac1aab0d300ae8 Added a little protection to migration query Just to be sure the query is filtered as expected to only affect shelf-based images. --- 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']); + } } /**