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

Explain why certain tables can be skipped #10

Open
danielbachhuber opened this issue May 22, 2017 · 7 comments
Open

Explain why certain tables can be skipped #10

danielbachhuber opened this issue May 22, 2017 · 7 comments

Comments

@danielbachhuber
Copy link
Member

We should have a more concise version of this in the command description:

One of the keys in each database table has to be marked as the primary key, or else WP-CLI will skip over it and output ‘skipped’ as shown above. To see if that’s your problem, use DESCRIBE to view the index data for one of the skipped tables, like this:

$ wp db query 'DESCRIBE wp_17_comments'

+----------------------+---------------------+------+-----+---------------------+-------+
| Field                | Type                | Null | Key | Default             | Extra |
+----------------------+---------------------+------+-----+---------------------+-------+
| comment_ID           | bigint(20) unsigned | NO   |     | NULL                |       |
| comment_post_ID      | bigint(20) unsigned | NO   |     | 0                   |       |
| comment_author       | tinytext            | NO   |     | NULL                |       |
| comment_author_email | varchar(100)        | NO   |     |                     |       |
| comment_author_url   | varchar(200)        | NO   |     |                     |       |
| comment_author_IP    | varchar(100)        | NO   |     |                     |       |
| comment_date         | datetime            | NO   |     | 0000-00-00 00:00:00 |       |
| comment_date_gmt     | datetime            | NO   |     | 0000-00-00 00:00:00 |       |
| comment_content      | text                | NO   |     | NULL                |       |
| comment_karma        | int(11)             | NO   |     | 0                   |       |
| comment_approved     | varchar(20)         | NO   |     | 1                   |       |
| comment_agent        | varchar(255)        | NO   |     |                     |       |
| comment_type         | varchar(20)         | NO   |     |                     |       |
| comment_parent       | bigint(20) unsigned | NO   |     | 0                   |       |
| user_id              | bigint(20) unsigned | NO   |     | 0                   |       |
+----------------------+---------------------+------+-----+---------------------+-------+

‘PRI’ should be listed in the Key column somewhere, but since it isn’t, WP-CLI doesn’t know which is the primary key and is consequently skipping the table. Since the example above is a WordPress comments table, comment_ID should have ‘PRI’ in the Key column. By looking at the table index data above (and thanks to help from @JPry), I was able to see that my table was missing much more than just the primary key and that an error had occurred when the database was exported/imported. So to fix the issue, I needed to get another copy of it and try the search-replace again.

From https://kellenmace.com/wp-cli-search-replace-tables-skipped/

Related https://wordpress.org/support/topic/wp-search-replace-skipped-tables/

@thejimbirch
Copy link

I ran into this today. I believe the --all-tables option helped me include the tables that were skipped. These seem to be tables added by custom and premium plugins.

My command ended up like this:

wp search-replace 'http://example.com' 'https://example.com' --skip-columns=guid --all-tables

@schlessera
Copy link
Member

Maybe this is a good first use case for the error message redirection discussed in wp-cli/wp-cli#4158 ?

@wpbullet
Copy link

wpbullet commented Nov 5, 2017

@thejimbirch I don't think the --all-tables flag will help with this. having run into this lately this was how I fixed the missing unique column issue on wp_options which hopefully helps others who run into this issue. I currently have no idea how these mysteriously disappear.

Was the idea to just have a footer on the output linking to a KB article or this github issue about why tables are skipped @schlessera and @danielbachhuber or was it something

@danielbachhuber
Copy link
Member Author

Was the idea to just have a footer on the output linking to a KB article or this github issue about why tables are skipped

See the first line of the issue:

We should have a more concise version of this in the command description:

The goal is to have a concise version of the explanation in the command description.

@wpbullet
Copy link

wpbullet commented Nov 6, 2017

To clarify the command description is this page https://developer.wordpress.org/cli/commands/search-replace/ and not something else, right?

Personally I think there should be some sort of Notes section for each command description page for caveats/gotchas etc

@courtneyaschwartz
Copy link

Have also encountered this. --all-tables didn't work. (We'd already been using it.) Seems to only occur with some commercial plugins. Might be noteworthy that this is on multi-site.

@mircobabini
Copy link

@schlessera Hacktoberfest this year? 🙃

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

6 participants