Allow migrate media command to be re-run
This commit is contained in:
parent
4dd4977dd9
commit
a5f146125b
1 changed files with 2 additions and 2 deletions
|
|
@ -43,7 +43,7 @@ class MigrateMedia extends Command
|
||||||
$this->withProgressBar($mediaEndpointMedia, function (Media $mediaEndpointMediaItem) {
|
$this->withProgressBar($mediaEndpointMedia, function (Media $mediaEndpointMediaItem) {
|
||||||
$note = Note::find($mediaEndpointMediaItem->note_id);
|
$note = Note::find($mediaEndpointMediaItem->note_id);
|
||||||
if ($note) {
|
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,
|
'path' => 'media'.DIRECTORY_SEPARATOR.$oldMediaItem->file_name,
|
||||||
'type' => 'image',
|
'type' => 'image',
|
||||||
]);
|
]);
|
||||||
$note->media()->attach($newMediaItem->id);
|
$note->media()->syncWithoutDetaching($newMediaItem->id);
|
||||||
|
|
||||||
// Copy the file
|
// Copy the file
|
||||||
Storage::disk('public')->writeStream('media'.DIRECTORY_SEPARATOR.$oldMediaItem->file_name, Storage::disk('s3')->readStream($oldMediaItem->id.DIRECTORY_SEPARATOR.$oldMediaItem->file_name));
|
Storage::disk('public')->writeStream('media'.DIRECTORY_SEPARATOR.$oldMediaItem->file_name, Storage::disk('s3')->readStream($oldMediaItem->id.DIRECTORY_SEPARATOR.$oldMediaItem->file_name));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue