Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a CLI migration command to update attachment file names #63

Closed
wants to merge 9 commits into from

Conversation

roborourke
Copy link
Contributor

@roborourke roborourke commented Nov 4, 2020

This does DB replacements on the post_content column only, and clears caches. It's going to be a pretty heavy process to run.

Solution to #43

@roborourke roborourke requested review from joehoyle and rmccue November 4, 2020 12:05
Copy link

@hm-linter hm-linter bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linting failed (153 errors).

(142 notices occurred in your codebase, but were on files/lines not included in this PR.)

inc/class-command.php Outdated Show resolved Hide resolved
inc/class-command.php Outdated Show resolved Hide resolved
@roborourke roborourke requested a review from joehoyle November 4, 2020 17:32
@roborourke
Copy link
Contributor Author

We could perhaps update the script to dump out the file name replacements as a series of CLI commands to run if anyone needs to update data other than the post_content

inc/class-tachyon.php Outdated Show resolved Hide resolved
inc/class-tachyon.php Outdated Show resolved Hide resolved
$count = WP_CLI::runcommand(
sprintf(
'search-replace %s %s --format=count --url=%s',
$size_data['file'],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going to be reeeeaaalllyyy slow!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep! I'm not sure it's really avoidable though. Would be great if search-replace supported arrays of things like str_replace()... Given it's a one time migration script it might not be so bad but this seems like the most robust way to do it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmm ok, lets go with it for now then!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ryan had some better suggestions to make it faster using transactions so going to try that out today

@roborourke
Copy link
Contributor Author

Added this migration command to a separate repo here instead so it's not dependent on Tachyon being active at the time.

https://github.com/humanmade/rename-images-command

@roborourke roborourke closed this Dec 2, 2020
@roborourke roborourke deleted the add-migration-command branch December 2, 2020 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants