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

db reset shouldn't drop the db #87

Closed
lucrus73 opened this issue Mar 9, 2018 · 5 comments
Closed

db reset shouldn't drop the db #87

lucrus73 opened this issue Mar 9, 2018 · 5 comments

Comments

@lucrus73
Copy link

lucrus73 commented Mar 9, 2018

wp db reset drops the entire database and recreates it. However, if you have multiple WP instances sharing the same DB (using different table prefixes) that kills all the instances, not just the one you need to reset.

Please either change the semantics of wp db reset or provide a new wp db clean command (or similar command name) that only drops the tables.

@marksabbath
Copy link
Collaborator

It does make sense since we do have the wp db drop. From what I can see, the best option would be:

  • Make wp db reset perform a DROP TABLE for each table using the $table_prefix;
  • Add a --re-create flag on wp db drop.

@lucrus73
Copy link
Author

The only problem I see with that solution is it breaks compatibility. Not an issue to me in particular, but I wonder if we should be concerned about that.

@danielbachhuber
Copy link
Member

wp db reset drops the entire database and recreates it

Correct, this is intentional.

However, if you have multiple WP instances sharing the same DB (using different table prefixes) that kills all the instances, not just the one you need to reset.

Right. Given command name is wp db reset, it makes logical sense that the command resets the database.

Please either change the semantics of wp db reset or provide a new wp db clean command (or similar command name) that only drops the tables.

Changing the semantics of wp db reset is an unnecessary breaking change. I'd be amenable to a wp db clean though.

@lucrus73
Copy link
Author

lucrus73 commented Mar 18, 2018

Correct, this is intentional.

But wp help db says:

reset Removes all tables from the database.

So the intention seems to drop the tables, not the whole database. Moreover, being a WordPress command, I believe it's understood it refers to the WordPress instance tables only.

Given command name is wp db reset, it makes logical sense that the command resets the database

So what's the difference between wp db drop && wp db create and wp db reset?

I'd be amenable to a wp db clean though.

That's inconsistent with what you said before. if wp db means "the whole db" by design, then wp db clean should not act only on the specific instance tables. In that case we need a new subcommand other than db that acts only on the specific instance tables.
However, since wp db tables already lists only the specific instance tables, I assume that your statement is not completely true, and that it isn't completely logical that wp db reset resets the whole database.

That being said, I'm perfectly ok with the wp db clean alternative. I'm only highlighting the reasons you provided for the wp db clean alternative are not that strong.

@danielbachhuber
Copy link
Member

So the intention seems to drop the tables, not the whole database. Moreover, being a WordPress command, I believe it's understood it refers to the WordPress instance tables only.

Sure. I'm open to a pull request that clarifies the description then.

However, since wp db tables already lists only the specific instance tables, I assume that your statement is not completely true, and that it isn't completely logical that wp db reset resets the whole database.

That being said, I'm perfectly ok with the wp db clean alternative. I'm only highlighting the reasons you provided for the wp db clean alternative are not that strong.

Ok. You can win the argument then. We're not changing the behavior of wp db reset though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants