Skip to content

Commit 59e90bf

Browse files
authored
Fix/unnecessary locking (#21)
* 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.
1 parent a5f3cb4 commit 59e90bf

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/Commands/MigrateDumpCommand.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ private static function mysqlSchemaDump(array $db_config, string $schema_sql_pat
141141
passthru(
142142
static::mysqlCommandPrefix($db_config)
143143
. ' --result-file=' . escapeshellarg($schema_sql_path)
144-
. ' --no-data',
144+
. ' --no-data'
145+
. ' --routines',
145146
$exit_code
146147
);
147148

@@ -167,6 +168,7 @@ private static function mysqlSchemaDump(array $db_config, string $schema_sql_pat
167168
. ' --no-create-info'
168169
. ' --skip-extended-insert'
169170
. ' --skip-routines'
171+
. ' --single-transaction'
170172
. ' --compact',
171173
$output,
172174
$exit_code
@@ -201,7 +203,8 @@ private static function mysqlDataDump(array $db_config, string $data_sql_path) :
201203
static::mysqlCommandPrefix($db_config)
202204
. ' --result-file=' . escapeshellarg($data_sql_path)
203205
. ' --no-create-info --skip-routines --skip-triggers'
204-
. ' --ignore-table=' . escapeshellarg($db_config['database'] . '.migrations'),
206+
. ' --ignore-table=' . escapeshellarg($db_config['database'] . '.migrations')
207+
. ' --single-transaction', // Avoid disruptive locks.
205208
$exit_code
206209
);
207210

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

240-
return 'mysqldump --routines --skip-add-drop-table'
243+
return 'mysqldump --skip-add-drop-table'
241244
. ' --skip-add-locks --skip-comments --skip-set-charset --tz-utc --set-gtid-purged=OFF'
242245
. ' --host=' . escapeshellarg($db_config['host'])
243246
. ' --port=' . escapeshellarg($db_config['port'])

0 commit comments

Comments
 (0)