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

Move specific DB tables (supporting wildcard names) #468

Open
alessandro-fazzi opened this issue Apr 16, 2018 · 11 comments
Open

Move specific DB tables (supporting wildcard names) #468

alessandro-fazzi opened this issue Apr 16, 2018 · 11 comments

Comments

@alessandro-fazzi
Copy link
Member

alessandro-fazzi commented Apr 16, 2018

Hello,

now that we have slowly moved along the way and we have declared wp-cli as a dependency, we have possibility to afford this feature in a secure, standard way.

I'm thinking about solving 2 different problems here:

  1. dump only tables with specific prefix
  2. dump only certain tables

The config inside movefile.yml would look like

database:
  name: 'mydb'
  password: 'mypwd'
  [...]
  tables:
    - 'wp_posts'
    - 'wp_users'

or

database:
  name: 'mydb'
  password: 'mypwd'
  [...]
  tables:
    - 'wp_*'

or a mix

database:
  name: 'mydb'
  password: 'mypwd'
  [...]
  tables:
    - 'custom_prefix_*'
    - 'wp_posts'

The implementation would rely on wp db tables command; slow (wp-cli is slow to load) but rock solid. I'd cycle over the array of strings tables and construct a string from the output of

wp db tables 'custom_prefix_*' --all-tables

intercepting the use of the wildcard and passing thus to wp-cli; or simply appending 'wp_posts' because no wildcard is used.

The resulting mysqldump command would be, e.g.:

mysqldump --host=localhost --user=root --result-file="/Users/fuzzy/dev/sshwordmove/wp-content/dump.sql" --default-character-set=utf8 sshwordmove wp_posts custom_prefix_table1 custom_prefix_table2

Tables would be specified for each environment (local and/or remote) based on the desired behaviour. Opening to scenarios where I can pull only wp_posts from production, but wp_users and wp_posts from staging.


Note:

@alessandro-fazzi
Copy link
Member Author

This feature embraces different previously discussed features such as #442 #219 and a request reported inside #432 (but was a bit OT there)

@alessandro-fazzi alessandro-fazzi added this to To do in v6.0 Apr 16, 2018
@taliesinpenbardd
Copy link

Following your last answer on #442 (and to follow this thread 😃) : yet simpler if --all-tables-with-prefix doesn't need help to get the db prefix.

@alessandro-fazzi
Copy link
Member Author

alessandro-fazzi commented Apr 16, 2018

Yep, simpler, but less powerful: if I'd be developing a plugin with a prefix like wpprefix_customprefix_teble it could be useful to customise the prefix. It could be over-engineered, but I'd like to find a feature which could rule them all.

@ThomasGHenry
Copy link

Happy Issue Anniversary! Did this happen?

@alessandro-fazzi
Copy link
Member Author

I can't assure when the feature will be implemented (it also has a blocker), but I can assure that when it will this issue will be updated.

@MarkErik
Copy link

If I am reading this correctly, it would allow to exclude the users from a DB push / pull operation?
This would be a fantastic feature.

@alessandro-fazzi
Copy link
Member Author

If I am reading this correctly, it would allow to exclude the users from a DB push / pull operation?
This would be a fantastic feature.

Hey @MarkErik the feature is a different one actually.

But the one you’re talking about already exists; please search for “forbid” in the documentation 😉

@MarkErik
Copy link

Dear @pioneerskies, my apologies, I might not have clearly commented what I was hoping for and perhaps for missing something in the documentation.

In my comment: "exclude the users from a DB push / pull operation" what I was hoping to say was that the registered WordPress users could be excluded from Push / Pull operations.

I had also opened a feature request expanding on this so that pages / posts / users etc could be selectively excluded from push / pull operations.

Note, I had tried the forbid command:
forbid:
push:
db: true

And as a test I registered a new WordPress user, and created a page locally, and as expected when I pushed, neither showed up on the production site.

My goal is that I can create new pages (perhaps with new plugins) locally and push them to the production server, and in most situations for safety prevent the accidental deletion of elements that I am not working with.

@alessandro-fazzi
Copy link
Member Author

In my comment: "exclude the users from a DB push / pull operation" what I was hoping to say was that the registered WordPress users could be excluded from Push / Pull operations.

@MarkErik you could try to exclude your wp_users table through mysqldump_options config. That won't consider consider user-related options which are on another table, but you'd accomplish to not pull/push registered users.

@MarkErik
Copy link

MarkErik commented Jan 4, 2020

@pioneerskies Thank you for that suggestion, I will give it a try. Feel free to remove my earlier comments if you'd like to keep the original feature discussion cleaner :)

@stale
Copy link

stale bot commented Apr 16, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
v6.0
  
To do
Development

No branches or pull requests

4 participants