Skip to content

Commit

Permalink
Remove --column-statistics for MariaDB schema dump
Browse files Browse the repository at this point in the history
When `php artisan schema:dump` is run with a MariaDB connection, the
warning message `mysqldump: unknown variable 'column-statistics=0'`
appears, but the dump is otherwise successful.

This is because the `--column-statistics` flag is MySQL specific, and
does not exist in MariaDB's version of `mysqldump`.

Let's remove the `--column-statistics` flag from the `schema:dump`
command when it is run against a MariaDB connection.

There should be no issues with removing the flag in MariaDB as the flag
has no effect otherwise and `schema:dump` still functions correctly
with MariaDB even with the flag removed.
  • Loading branch information
Xenonym committed Sep 21, 2020
1 parent 12ba0d9 commit f4e4bca
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Illuminate/Database/Schema/MySqlSchemaState.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,10 @@ public function load($path)
*/
protected function baseDumpCommand()
{
$columnStatistics = $this->connection->isMaria() ? '' : '--column-statistics=0';
$gtidPurged = $this->connection->isMaria() ? '' : '--set-gtid-purged=OFF';

return 'mysqldump '.$gtidPurged.' --column-statistics=0 --skip-add-drop-table --skip-add-locks --skip-comments --skip-set-charset --tz-utc --host="${:LARAVEL_LOAD_HOST}" --port="${:LARAVEL_LOAD_PORT}" --user="${:LARAVEL_LOAD_USER}" --password="${:LARAVEL_LOAD_PASSWORD}" "${:LARAVEL_LOAD_DATABASE}"';
return 'mysqldump '.$gtidPurged.' '.$columnStatistics.' --skip-add-drop-table --skip-add-locks --skip-comments --skip-set-charset --tz-utc --host="${:LARAVEL_LOAD_HOST}" --port="${:LARAVEL_LOAD_PORT}" --user="${:LARAVEL_LOAD_USER}" --password="${:LARAVEL_LOAD_PASSWORD}" "${:LARAVEL_LOAD_DATABASE}"';
}

/**
Expand Down

0 comments on commit f4e4bca

Please sign in to comment.