Merge pull request 'MTM Allow migrate media command to be re-run' (#72) from develop into main

Reviewed-on: #72
This commit is contained in:
Jonny Barnes 2026-01-09 17:35:28 +01:00
commit b4fbc27abe

View file

@ -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));