wp-cli / search-replace-command

Searches/replaces strings in the database.
MIT License
57 stars 45 forks source link

Specify Key value when Search and Replace in Sterilized Data. #105

Open adampatterson opened 5 years ago

adampatterson commented 5 years ago

I came across the scenario of moving my S3 bucket and while doing that also changed the path.

I upload an image, It is sent to Kraken.io, and Uploaded to S3 using Media Offload.

I made a copy locally of the database and ran wp search-replace 'old-bucket 'new-bucket. To my joy, the serialized string was also updated.

My next task was to update the media path. Previously it would have been old-bucket/year/month

Now it would be new-bucket/media/year/month

If I were to search and replace based off of /2015 I am going to affect the _wp_attached_file and _wp_attachment_metadata

Is it possible to search inside of two columns where one column value is equal to something else?

Like look in meta_value where meta_key == amazonS3_info?