Skip to content

Commit

Permalink
Add transactions (#16)
Browse files Browse the repository at this point in the history
* Add transactions

If there is any failure in database, leave the database without any changes.

* Update UpdateAttribute.php

* Update UpdateAttribute.php

* Apply fixes from StyleCI (#17)
  • Loading branch information
sausin authored Apr 15, 2020
1 parent a508b7f commit 8d13e8e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/UpdateAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ protected function updateAutoIncrement($driver, $table): void
{
$method = "update{$driver}AutoIncrement";

$this->{$method}($table);
// perform changes as a transaction to avoid
// borking the database in case of issues.
DB::transaction(function () use ($method, $table) {
$this->{$method}($table);
});
}

protected function updateMysqlAutoIncrement($table): void
Expand Down

0 comments on commit 8d13e8e

Please sign in to comment.