iandunn / wp-cli-rename-db-prefix

A WP-CLI command to rename WordPress' database prefix
108 stars 18 forks source link

Add flag to run in dry mode #5

Closed ocean90 closed 7 years ago

ocean90 commented 7 years ago

I was curious what queries the command would run so I thought a --dry-run argument would be a nice addition. Instead of executing the queries it would just print them to STDOUT.

$ wp rename-db-prefix test_ --dry-run

Warning: Use this at your own risk. If something goes wrong, it could break your site. Before running this, make sure to back up your `wp-config.php` file and run `wp db export`.
Running in dry run mode.

RENAME TABLE `wp_commentmeta` TO `test_commentmeta`;
RENAME TABLE `wp_comments` TO `test_comments`;
RENAME TABLE `wp_links` TO `test_links`;
....

Let me know what you think about this idea.

iandunn commented 7 years ago

Looks good to me, thanks!

ocean90 commented 7 years ago

@iandunn Thanks for merging! I should have noted this was kind of WIP, but at least it works. :)

I think we should improve some of the feedback messages (don't show "Successfully renamed database prefix." on dry-run) and remove the tabs/new lines from the update queries so they are in one line.

iandunn commented 7 years ago

No worries, feel free to push whatever commits you think are appropriate. I trust your judgement :)