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 · 5 comments

Comments

4 participants
@danielbachhuber
Member

danielbachhuber commented May 22, 2017

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

This comment has been minimized.

Show comment
Hide comment
@thejimbirch

thejimbirch Sep 21, 2017

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

thejimbirch commented Sep 21, 2017

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

This comment has been minimized.

Show comment
Hide comment
@schlessera

schlessera Sep 24, 2017

Member

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

Member

schlessera commented Sep 24, 2017

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

@wpbullet

This comment has been minimized.

Show comment
Hide comment
@wpbullet

wpbullet 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

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

This comment has been minimized.

Show comment
Hide comment
@danielbachhuber

danielbachhuber Nov 6, 2017

Member

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.

Member

danielbachhuber commented Nov 6, 2017

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

This comment has been minimized.

Show comment
Hide comment
@wpbullet

wpbullet 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

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

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