2
2
3
3
namespace Illuminate \Database \Schema ;
4
4
5
+ use Exception ;
6
+ use Illuminate \Support \Str ;
7
+ use Symfony \Component \Process \Process ;
8
+
5
9
class MySqlSchemaState extends SchemaState
6
10
{
7
11
/**
@@ -12,9 +16,9 @@ class MySqlSchemaState extends SchemaState
12
16
*/
13
17
public function dump ($ path )
14
18
{
15
- $ this ->makeProcess (
19
+ $ this ->executeDumpProcess ( $ this -> makeProcess (
16
20
$ 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 ()), [
18
22
'LARAVEL_LOAD_PATH ' => $ path ,
19
23
]));
20
24
@@ -46,9 +50,9 @@ protected function removeAutoIncrementingState(string $path)
46
50
*/
47
51
protected function appendMigrationData (string $ path )
48
52
{
49
- with ( $ process = $ this ->makeProcess (
53
+ $ process = $ this -> executeDumpProcess ( $ this ->makeProcess (
50
54
$ 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 ()), [
52
56
//
53
57
]));
54
58
@@ -98,4 +102,29 @@ protected function baseVariables(array $config)
98
102
'LARAVEL_LOAD_DATABASE ' => $ config ['database ' ],
99
103
];
100
104
}
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
+ }
101
130
}
0 commit comments