mirror of
https://github.com/BookStackApp/BookStack.git
synced 2026-07-16 05:33:49 +03:00
Images: Added nulling of image page relation on page delete
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
use BookStack\Permissions\JointPermissionBuilder;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
@@ -66,6 +67,15 @@ return new class extends Migration
|
||||
DB::table('images')->where('uploaded_to', '=', 0)->update(['uploaded_to' => null]);
|
||||
DB::table('activities')->where('loggable_id', '=', 0)->update(['loggable_id' => null]);
|
||||
|
||||
// Clean up any orphaned gallery/drawio images to nullify their page relation
|
||||
DB::table('images')
|
||||
->whereIn('type', ['gallery', 'drawio'])
|
||||
->whereNotIn('uploaded_to', function (Builder $query) {
|
||||
$query->select('id')
|
||||
->from('entities')
|
||||
->where('type', '=', 'page');
|
||||
})->update(['uploaded_to' => null]);
|
||||
|
||||
// Rebuild joint permissions if needed
|
||||
// This was moved here from 2023_01_24_104625_refactor_joint_permissions_storage since the changes
|
||||
// made for this release would mean our current logic would not be compatible with
|
||||
|
||||
Reference in New Issue
Block a user