From a5f146125b81a3b1d92eb10b0e82dcb35d7d3006 Mon Sep 17 00:00:00 2001 From: Jonny Barnes Date: Fri, 9 Jan 2026 14:21:37 +0000 Subject: [PATCH] Allow migrate media command to be re-run --- app/Console/Commands/MigrateMedia.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Console/Commands/MigrateMedia.php b/app/Console/Commands/MigrateMedia.php index 008a263f..9d81ed34 100644 --- a/app/Console/Commands/MigrateMedia.php +++ b/app/Console/Commands/MigrateMedia.php @@ -43,7 +43,7 @@ class MigrateMedia extends Command $this->withProgressBar($mediaEndpointMedia, function (Media $mediaEndpointMediaItem) { $note = Note::find($mediaEndpointMediaItem->note_id); if ($note) { - $note->media()->attach($mediaEndpointMediaItem->id); + $note->media()->syncWithoutDetaching($mediaEndpointMediaItem->id); } }); @@ -87,7 +87,7 @@ class MigrateMedia extends Command 'path' => 'media'.DIRECTORY_SEPARATOR.$oldMediaItem->file_name, 'type' => 'image', ]); - $note->media()->attach($newMediaItem->id); + $note->media()->syncWithoutDetaching($newMediaItem->id); // Copy the file Storage::disk('public')->writeStream('media'.DIRECTORY_SEPARATOR.$oldMediaItem->file_name, Storage::disk('s3')->readStream($oldMediaItem->id.DIRECTORY_SEPARATOR.$oldMediaItem->file_name)); -- 2.55.0