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 wp db clean command #93

Merged
merged 14 commits into from
May 8, 2018
Merged

Conversation

marksabbath
Copy link
Collaborator

wp db clean

Introducing new wp db clean. This new command drops only the tables that are present in $table_prefix.

@marksabbath
Copy link
Collaborator Author

Will take a look at the errors later today.

@schlessera
Copy link
Member

@marksabbath Are you still up for working on this command?

Quick note about the PR: An unrelated test now fails because you changed surrounding whitespace that is unrelated to your code change. Please make sure your editor does not introduce unwanted changes, to keep the PR clean and targeted.

@marksabbath
Copy link
Collaborator Author

Yes @schlessera working on it BTW. Planning to finish that up by today.

@marksabbath
Copy link
Collaborator Author

Hey, @schlessera it seems that 2 errors not related to my code are blocking this merge.

1 - WordPress 5.0 seems to have changed the tables on Multisite installs (see https://travis-ci.org/wp-cli/db-command/jobs/362222469);
2 - Composer running out of memory on PHP5.3 (see https://travis-ci.org/wp-cli/db-command/jobs/362222470).

Should I update the tests of wp db tables (maybe using --scope=old) on multisite's test?
How could I get rid of #2?

@schlessera
Copy link
Member

@marksabbath Both issues should be resolved. If you merge latest master, tests should pass.

@marksabbath
Copy link
Collaborator Author

Done @schlessera all good now! Thanks man!

@marksabbath
Copy link
Collaborator Author

Anything else we would need to do to move this forward @schlessera ?

@schlessera
Copy link
Member

Thanks for the pull request, @marksabbath, and sorry for the wait. I did some minor changes, and this is good to be merged now.

@schlessera schlessera added this to the 1.3.4 milestone May 8, 2018
@schlessera schlessera merged commit ce8c51a into wp-cli:master May 8, 2018
@schlessera schlessera changed the title wp db clean implemented. Add wp db clean command May 8, 2018
@marksabbath
Copy link
Collaborator Author

This should resolve #92

@canonex
Copy link

canonex commented Oct 2, 2019

Hi, this command is not removing all tables with $table_prefix: custom tables are not removed.

If we have
$table_prefix = "wp_";
and install some plugins (ex. Pods with or without Table Storage plugin) that creates tables like
wp_pods_company
or
wp_podsrel
or we manually create tables with the correct prefix like
wp_goodtable
the command fails to delete these new tables.
So not "all" tables with $table_prefix are removed.

Did I miss something or is it a bug?
Thank you,
Riccardo

ps. I have read that db clear was made to "limit" db reset: I'm using wp db to link git commit to db status and clean command is the best option I found.
Reset is not at all a good replacement:

  • if there are other installations on the database they are deleted
  • if there are indexes, procedures or triggers, they are deleted

danielbachhuber pushed a commit that referenced this pull request Nov 18, 2022
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.

3 participants