db-command icon indicating copy to clipboard operation
db-command copied to clipboard

Docs: Add `--add-drop-table` to export command docblock

Open peterwilsoncc opened this issue 1 year ago • 3 comments

Bug Report

Describe the current, buggy behavior

The first example in the wp db export docs includes the switch --add-drop-table

# Export database with drop query included
$ wp db export --add-drop-table
Success: Exported to 'wordpress_dbase-db72bb5.sql'.

However the switch is not included in the options section of the docblock.

Describe how other contributors can replicate this bug

See https://developer.wordpress.org/cli/commands/db/export/

Describe what you would expect as the correct outcome

Add the switch to the options section

Let us know what environment you are running this on

OS:	Linux 5.15.0-92-generic #102-Ubuntu SMP Wed Jan 10 09:37:39 UTC 2024 aarch64
Shell:	/bin/bash
PHP binary:	/usr/bin/php7.4
PHP version:	7.4.33
php.ini used:	/etc/php/7.4/cli/php.ini
MySQL binary:	/usr/bin/mysql
MySQL version:	mysql  Ver 8.0.36-0ubuntu0.22.04.1 for Linux on aarch64 ((Ubuntu))
SQL modes:	
WP-CLI root dir:	phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:	phar://wp-cli.phar/vendor
WP_CLI phar path:	/vagrant/content
WP-CLI packages dir:	
WP-CLI cache dir:	/home/vagrant/.wp-cli/cache
WP-CLI global config:	/home/vagrant/.wp-cli/config.yml
WP-CLI project config:	/vagrant/wp-cli.yml
WP-CLI version:	2.10.0

Provide a possible solution

As above.

Provide additional context/Screenshots

peterwilsoncc avatar Aug 12 '24 00:08 peterwilsoncc

This example looks like mistake to me because even without that flag, SQL dump has DROP TABLE IF EXISTS. May be it should be removed.

ernilambar avatar Aug 12 '24 04:08 ernilambar

@swissspidy See above comment.

ernilambar avatar Aug 12 '24 07:08 ernilambar

Hmm apologies, I missed this conversation here.

add-drop-table is indeed the default in mysqldump via the --opt flag (which is enabled by default). See https://dev.mysql.com/doc/refman/8.4/en/mysqldump.html#option_mysqldump_opt

It's useful when you do e.g. wp db export --skip-opt --add-drop-table though.

I was perhaps a bit overly quick to merge #263. I realized we don't mention all the other mysqldump options in the docs, only the ones relevant for WP-CLI itself. So I think we should remove it again but make the docs and examples clearer what's for mysqldump and what's for WP-CLI.

swissspidy avatar Aug 12 '24 08:08 swissspidy