3
3
Object . defineProperty ( exports , "__esModule" , {
4
4
value : true
5
5
} ) ;
6
- exports . removeDb = exports . importDb = exports . clearDb = exports . unzipDb = exports . checkForDb = exports . importDbQuery = exports . doLocalDbDump = exports . doImportDb = exports . dropDbQuery = exports . doDropAllDbTables = exports . getDbDumpZipCommands = void 0 ;
6
+ exports . isMysql8 = exports . removeDb = exports . importDb = exports . clearDb = exports . unzipDb = exports . checkForDb = exports . importDbQuery = exports . doLocalDbDump = exports . doImportDb = exports . dropDbQuery = exports . doDropAllDbTables = exports . getDbDumpZipCommands = void 0 ;
7
7
8
8
var _promiseMysql = _interopRequireDefault ( require ( "promise-mysql" ) ) ;
9
9
10
+ var _react = require ( "react" ) ;
11
+
10
12
var _utils = require ( "./utils" ) ;
11
13
12
14
function _interopRequireDefault ( obj ) { return obj && obj . __esModule ? obj : { default : obj } ; }
@@ -89,6 +91,11 @@ const doLocalDbDump =
89
91
function ( ) {
90
92
var _ref3 = _asyncToGenerator ( function * ( config ) {
91
93
let errorMessage ;
94
+ config = Object . assign ( config , {
95
+ isMysql8 : yield isMysql8 ( {
96
+ localCmd : _utils . cmdPromise
97
+ } )
98
+ } ) ;
92
99
yield ( 0 , _utils . cmdPromise ) ( getDbDumpZipCommands ( config ) ) . catch ( e => errorMessage = e ) ;
93
100
if ( errorMessage ) return new Error ( errorMessage ) ;
94
101
} ) ;
@@ -106,9 +113,10 @@ const getDbDumpZipCommands = ({
106
113
user,
107
114
password,
108
115
database,
109
- gzipFilePath
116
+ gzipFilePath,
117
+ isMysql8 = false
110
118
} ) => // Dump and zip the db - this can make it around 9 times smaller
111
- `mysqldump --host='${ host } ' --port='${ port } ' --user='${ user } ' --password='${ password } ' --no-tablespaces --column-statistics=0 ${ database } | gzip > '${ gzipFilePath } '` ;
119
+ `mysqldump --host='${ host } ' --port='${ port } ' --user='${ user } ' --password='${ password } ' --no-tablespaces ${ isMysql8 ? ' --column-statistics=0' : '' } ${ database } | gzip > '${ gzipFilePath } '` ;
112
120
113
121
exports . getDbDumpZipCommands = getDbDumpZipCommands ;
114
122
@@ -263,6 +271,62 @@ function () {
263
271
return function removeDb ( _x8 ) {
264
272
return _ref8 . apply ( this , arguments ) ;
265
273
} ;
274
+ } ( ) ; // Check the version of mysqldump (mysql)
275
+ // cmd can be either
276
+ // - sshConn(remote)
277
+ // or
278
+ // - localCmd(local)
279
+
280
+
281
+ exports . removeDb = removeDb ;
282
+
283
+ const isMysql8 =
284
+ /*#__PURE__*/
285
+ function ( ) {
286
+ var _ref9 = _asyncToGenerator ( function * ( {
287
+ sshConn,
288
+ localCmd
289
+ } ) {
290
+ if ( sshConn ) {
291
+ let output = "" ,
292
+ errorMessage = "" ;
293
+ yield sshConn . execCommand ( `mysqldump --version` ) . then ( ( {
294
+ stdout,
295
+ stderr
296
+ } ) => {
297
+ output = stdout ; // If error running command
298
+
299
+ if ( stderr ) errorMessage = `There was an issue checking mysql version\n\n${ stderr } ` ;
300
+ } ) ;
301
+
302
+ if ( output . indexOf ( "Ver 8" ) !== - 1 ) {
303
+ return true ;
304
+ }
305
+
306
+ return false ;
307
+ } else if ( localCmd ) {
308
+ let output = "" ,
309
+ errorMessage = "" ;
310
+ yield localCmd ( `mysqldump --version` ) . then ( stdout => {
311
+ output = stdout ;
312
+ } ) . catch ( stderr => {
313
+ // If error running command
314
+ if ( stderr ) errorMessage = `There was an issue checking mysql version\n\n${ stderr } ` ;
315
+ } ) ;
316
+
317
+ if ( output . indexOf ( "Ver 8" ) !== - 1 ) {
318
+ return true ;
319
+ }
320
+
321
+ return false ;
322
+ }
323
+
324
+ return false ;
325
+ } ) ;
326
+
327
+ return function isMysql8 ( _x9 ) {
328
+ return _ref9 . apply ( this , arguments ) ;
329
+ } ;
266
330
} ( ) ;
267
331
268
- exports . removeDb = removeDb ;
332
+ exports . isMysql8 = isMysql8 ;
0 commit comments