Skip to content

Commit

Permalink
[5.5] Add option to disable wrapping Migration in transaction (#22757)
Browse files Browse the repository at this point in the history
* Add option to disable wrapping Migration in transaction

* Update Migration.php

* Update Migrator.php
  • Loading branch information
RobvH authored and taylorotwell committed Jan 12, 2018
1 parent fcd2b9e commit e36c639
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Illuminate/Database/Migrations/Migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ abstract class Migration
*/
protected $connection;

/**
* Enables, if supported, wrapping the migration within a transaction.
*
* @var bool
*/
public $withinTransaction = true;

/**
* Get the migration connection name.
*
Expand Down
1 change: 1 addition & 0 deletions src/Illuminate/Database/Migrations/Migrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ protected function runMigration($migration, $method)
};

$this->getSchemaGrammar($connection)->supportsSchemaTransactions()
&& $migration->withinTransaction
? $connection->transaction($callback)
: $callback();
}
Expand Down

0 comments on commit e36c639

Please sign in to comment.