Skip to content

Commit

Permalink
Merge pull request #13 from xfolder/main
Browse files Browse the repository at this point in the history
add --skip-tz-utc option to mysqldump
  • Loading branch information
dcblogdev authored Dec 28, 2022
2 parents 9884c18 + 347b4fe commit 9a35d3b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ To specify a different local database connection:
LOCAL_TARGET_CONNECTION=different_mysql_connection
```

For only mysqldump:
```
REMOTE_MYSQLDUMP_SKIP_TZ_UTC=true
```

## Usage

To export a remote database to OVERRIDE your local database by running:
Expand Down
2 changes: 2 additions & 0 deletions config/dbsync.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,6 @@
* Sets the target databse connection
*/
'targetConnection' => env('LOCAL_TARGET_CONNECTION', 'mysql'),

'mysqldumpSkipTzUtc' => env('REMOTE_MYSQLDUMP_SKIP_TZ_UTC', false),
];
3 changes: 2 additions & 1 deletion src/Console/DbSyncCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public function handle(): bool
$importSqlFile = config('dbsync.importSqlFile');
$removeFileAfterImport = config('dbsync.removeFileAfterImport');
$fileName = $this->option('filename') ?? config('dbsync.defaultFileName');
$mysqldumpSkipTzUtc = config('dbsync.mysqldumpSkipTzUtc') ? '--skip-tz-utc' : '';

$targetConnection = config('dbsync.targetConnection');

Expand All @@ -53,7 +54,7 @@ public function handle(): bool
if ($useSsh === true) {
exec("ssh $sshUsername@$host -p$sshPort mysqldump -P$port -u$username -p$password $database $ignoreString > $fileName", $output);
} else {
exec("mysqldump -h$host -P$port -u$username -p$password $database $ignoreString --column-statistics=0 > $fileName", $output);
exec("mysqldump -h$host -P$port -u$username -p$password $database $ignoreString $mysqldumpSkipTzUtc --column-statistics=0 > $fileName", $output);
}

$this->comment(implode(PHP_EOL, $output));
Expand Down

0 comments on commit 9a35d3b

Please sign in to comment.