Skip to content

Commit

Permalink
Fix/unnecessary locking (#21)
Browse files Browse the repository at this point in the history
* fix(MigrateDumpCommand): Only include routines when dumping structure/schema.

* fix(MigrateDumpCommand): Use single transaction to avoid locking.

* chore(MigrateDumpCommand): Single transaction even for migrations table.
  • Loading branch information
paulrrogers authored Jul 16, 2020
1 parent a5f3cb4 commit 59e90bf
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Commands/MigrateDumpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ private static function mysqlSchemaDump(array $db_config, string $schema_sql_pat
passthru(
static::mysqlCommandPrefix($db_config)
. ' --result-file=' . escapeshellarg($schema_sql_path)
. ' --no-data',
. ' --no-data'
. ' --routines',
$exit_code
);

Expand All @@ -167,6 +168,7 @@ private static function mysqlSchemaDump(array $db_config, string $schema_sql_pat
. ' --no-create-info'
. ' --skip-extended-insert'
. ' --skip-routines'
. ' --single-transaction'
. ' --compact',
$output,
$exit_code
Expand Down Expand Up @@ -201,7 +203,8 @@ private static function mysqlDataDump(array $db_config, string $data_sql_path) :
static::mysqlCommandPrefix($db_config)
. ' --result-file=' . escapeshellarg($data_sql_path)
. ' --no-create-info --skip-routines --skip-triggers'
. ' --ignore-table=' . escapeshellarg($db_config['database'] . '.migrations'),
. ' --ignore-table=' . escapeshellarg($db_config['database'] . '.migrations')
. ' --single-transaction', // Avoid disruptive locks.
$exit_code
);

Expand Down Expand Up @@ -237,7 +240,7 @@ private static function mysqlCommandPrefix(array $db_config) : string
// Not including connection name in file since typically only one DB.
// Excluding any hash or date suffix since only current is relevant.

return 'mysqldump --routines --skip-add-drop-table'
return 'mysqldump --skip-add-drop-table'
. ' --skip-add-locks --skip-comments --skip-set-charset --tz-utc --set-gtid-purged=OFF'
. ' --host=' . escapeshellarg($db_config['host'])
. ' --port=' . escapeshellarg($db_config['port'])
Expand Down

0 comments on commit 59e90bf

Please sign in to comment.