search-replace-command
search-replace-command copied to clipboard
Explain why certain tables can be skipped
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/
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
Maybe this is a good first use case for the error message redirection discussed in https://github.com/wp-cli/wp-cli/issues/4158 ?
@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
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.
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
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.
@schlessera Hacktoberfest this year? 🙃