@@ -206,7 +206,6 @@ export function buildPostgreSQLImportCommand(options) {
206206 */
207207export function buildMongoDBRestoreCommand ( options ) {
208208 const {
209- database,
210209 user,
211210 password,
212211 host = 'localhost' ,
@@ -477,43 +476,43 @@ export function buildEstimateSizeCommand(type, database, options = {}) {
477476 const { user, password, host = 'localhost' , port } = options ;
478477
479478 switch ( type ) {
480- case DB_TYPES . MYSQL : {
481- let command = 'mysql' ;
482- if ( user ) command += ` -u${ user } ` ;
483- if ( password ) command += ` -p'${ password } '` ;
484- if ( host ) command += ` -h ${ host } ` ;
485- if ( port ) command += ` -P ${ port } ` ;
486- command += ` -e "SELECT SUM(data_length + index_length) FROM information_schema.TABLES WHERE table_schema='${ database } ';" | tail -n 1` ;
487- return command ;
488- }
479+ case DB_TYPES . MYSQL : {
480+ let command = 'mysql' ;
481+ if ( user ) command += ` -u${ user } ` ;
482+ if ( password ) command += ` -p'${ password } '` ;
483+ if ( host ) command += ` -h ${ host } ` ;
484+ if ( port ) command += ` -P ${ port } ` ;
485+ command += ` -e "SELECT SUM(data_length + index_length) FROM information_schema.TABLES WHERE table_schema='${ database } ';" | tail -n 1` ;
486+ return command ;
487+ }
489488
490- case DB_TYPES . POSTGRESQL : {
491- let command = '' ;
492- if ( password ) {
493- command = `PGPASSWORD='${ password } ' ` ;
489+ case DB_TYPES . POSTGRESQL : {
490+ let command = '' ;
491+ if ( password ) {
492+ command = `PGPASSWORD='${ password } ' ` ;
493+ }
494+ command += 'psql' ;
495+ if ( user ) command += ` -U ${ user } ` ;
496+ if ( host ) command += ` -h ${ host } ` ;
497+ if ( port ) command += ` -p ${ port } ` ;
498+ command += ` -d ${ database } ` ;
499+ command += ` -t -c "SELECT pg_database_size('${ database } ');" | sed 's/^[ \\t]*//'` ;
500+ return command ;
494501 }
495- command += 'psql' ;
496- if ( user ) command += ` -U ${ user } ` ;
497- if ( host ) command += ` -h ${ host } ` ;
498- if ( port ) command += ` -p ${ port } ` ;
499- command += ` -d ${ database } ` ;
500- command += ` -t -c "SELECT pg_database_size('${ database } ');" | sed 's/^[ \\t]*//'` ;
501- return command ;
502- }
503502
504- case DB_TYPES . MONGODB : {
505- let command = 'mongo' ;
506- if ( host ) command += ` --host ${ host } ` ;
507- if ( port ) command += ` --port ${ port } ` ;
508- if ( user ) command += ` --username ${ user } ` ;
509- if ( password ) command += ` --password '${ password } '` ;
510- command += ` ${ database } ` ;
511- command += ' --quiet --eval "db.stats().dataSize"' ;
512- return command ;
513- }
503+ case DB_TYPES . MONGODB : {
504+ let command = 'mongo' ;
505+ if ( host ) command += ` --host ${ host } ` ;
506+ if ( port ) command += ` --port ${ port } ` ;
507+ if ( user ) command += ` --username ${ user } ` ;
508+ if ( password ) command += ` --password '${ password } '` ;
509+ command += ` ${ database } ` ;
510+ command += ' --quiet --eval "db.stats().dataSize"' ;
511+ return command ;
512+ }
514513
515- default :
516- throw new Error ( `Unknown database type: ${ type } ` ) ;
514+ default :
515+ throw new Error ( `Unknown database type: ${ type } ` ) ;
517516 }
518517}
519518
0 commit comments