Skip to content

Commit d67be13

Browse files
committed
update schema state
1 parent 4026844 commit d67be13

File tree

1 file changed

+33
-4
lines changed

1 file changed

+33
-4
lines changed

src/Illuminate/Database/Schema/MySqlSchemaState.php

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
namespace Illuminate\Database\Schema;
44

5+
use Exception;
6+
use Illuminate\Support\Str;
7+
use Symfony\Component\Process\Process;
8+
59
class MySqlSchemaState extends SchemaState
610
{
711
/**
@@ -12,9 +16,9 @@ class MySqlSchemaState extends SchemaState
1216
*/
1317
public function dump($path)
1418
{
15-
$this->makeProcess(
19+
$this->executeDumpProcess($this->makeProcess(
1620
$this->baseDumpCommand().' --routines --result-file=$LARAVEL_LOAD_PATH --no-data'
17-
)->mustRun($this->output, array_merge($this->baseVariables($this->connection->getConfig()), [
21+
), $this->output, array_merge($this->baseVariables($this->connection->getConfig()), [
1822
'LARAVEL_LOAD_PATH' => $path,
1923
]));
2024

@@ -46,9 +50,9 @@ protected function removeAutoIncrementingState(string $path)
4650
*/
4751
protected function appendMigrationData(string $path)
4852
{
49-
with($process = $this->makeProcess(
53+
$process = $this->executeDumpProcess($this->makeProcess(
5054
$this->baseDumpCommand().' migrations --no-create-info --skip-extended-insert --skip-routines --compact'
51-
))->mustRun(null, array_merge($this->baseVariables($this->connection->getConfig()), [
55+
), null, array_merge($this->baseVariables($this->connection->getConfig()), [
5256
//
5357
]));
5458

@@ -98,4 +102,29 @@ protected function baseVariables(array $config)
98102
'LARAVEL_LOAD_DATABASE' => $config['database'],
99103
];
100104
}
105+
106+
/**
107+
* Execute the given dump process.
108+
*
109+
* @param \Symfony\Component\Process\Process $process
110+
* @param callable $output
111+
* @param array $variables
112+
* @return \Symfony\Component\Process\Process
113+
*/
114+
protected function executeDumpProcess(Process $process, $output, array $variables)
115+
{
116+
try {
117+
$process->mustRun($output, $variables);
118+
} catch (Exception $e) {
119+
if (Str::contains($e->getMessage(), 'column_statistics')) {
120+
$process = Process::fromShellCommandLine(
121+
str_replace(' --column-statistics=0', '', $process->getCommandLine())
122+
);
123+
124+
return $this->executeDumpProcess($process, $output, $variables);
125+
}
126+
}
127+
128+
return $process;
129+
}
101130
}

0 commit comments

Comments
 (0)