]> BookStack Code Mirror - bookstack/commitdiff
Added a little protection to migration query
authorDan Brown <redacted>
Thu, 8 Sep 2022 11:26:14 +0000 (12:26 +0100)
committerDan Brown <redacted>
Thu, 8 Sep 2022 11:26:14 +0000 (12:26 +0100)
Just to be sure the query is filtered as expected to only affect
shelf-based images.

database/migrations/2022_09_02_082910_fix_shelf_cover_image_types.php

index 837bdfe244ddcc6f907f9b3224cd6c2e95f266b3..a9a413607da8b050b0d0eea7a5bba021b293792b 100644 (file)
@@ -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']);
+        }
     }
 
     /**