Skip to content

Commit ea507b3

Browse files
refactor dump db command
refactor dump db command
2 parents c7438ca + 760bbba commit ea507b3

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/Console/DumpCommand.php

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,34 +32,30 @@ public function handle()
3232

3333
$this->line('Dumpping...');
3434
$this->line('');
35-
36-
$migration = 'sla_'.gmdate('Y_m_d_His').'.sql';
35+
$migration = 'sla_' . gmdate('Y_m_d_His') . '.sql';
3736

3837
$path = app_path('../database/sla_dumps');
3938

4039
if (!File::exists($path)) {
4140
File::makeDirectory($path, 493, true);
4241
}
4342

44-
$dumpMigration = $path.'/'.$migration;
43+
$dumpMigration = $path . '/' . $migration;
44+
45+
$this->info('Output path will be: ' . $dumpMigration);
46+
47+
exec('mysqldump -u ' . env('DB_USERNAME') . ' -p' . env('DB_PASSWORD') . ' ' . env('DB_DATABASE') . ' -r ' . $dumpMigration . ' 2>/dev/null', $output, $return_var);
4548

46-
$this->info('Output path will be: '.$dumpMigration);
47-
$this->line('');
48-
exec('mysqldump -u '.env('DB_USERNAME').' -p '.env('DB_DATABASE').' -r '.$dumpMigration, $output, $return_var);
4949
$this->line('');
5050

5151
if ($return_var != 0) {
5252
File::delete($dumpMigration);
5353

5454
$this->error('Dumpping error!');
5555
} else {
56-
$this->line('Dumpping Done!');
56+
$this->info('Dumpping Done!');
5757
}
5858

5959
$this->line('');
60-
$this->line('***');
61-
$this->line('');
62-
$this->info('Done!');
63-
$this->line(' _________________________________________________________________________________________________ ');
6460
}
6561
}

0 commit comments

Comments
 (0)