bender_michael's avatar

DB Transaction not rolling back in simple test

I'm wondering what I'm doing wrong here. I'm just trying what I think is a very basic transaction test because I noticed records not rolling back in the more complex transaction. Same result using closure method.

$model = new MyEloquentModel();
$model->prop = "value";

DB::beginTransaction();
$model->save();
DB::rollBack();
dd("finished");

Check my database and the MyEloquentModel() record is there. Using Laravel 5.4 with MySQL 5.6 - InnoDB tables.

0 likes
2 replies
aricci's avatar

Appears to be working just fine with Laravel 5.4 and MySQL 5.5 (InnoDB). Maybe delete the record in the DB and run this again just to make sure the record wasn't there from previous tests? Unless it's related to MySQL 5.6.

bender_michael's avatar

Thanks aricci. I have tried deleting and running many variations... all with the same result. I'm not sure what kind of settings my DB could have that would be blocking this. It is running as a queued job (although I've been testing with the sync queue driver). Maybe the queued natures of it is causing an issue?

Please or to participate in this conversation.