abbood's avatar

getting cannot rollback - no transaction when using slqite for laravel testing

I'm trying to use in memory sqllite for my laravel testing, by putting this in my .env file:

'sqlite_testing' => [
    'driver'   => 'sqlite',
    'database' => ':memory:',
    'prefix'   => '',
]

(it's in my .env.testing file, which is the same env specified in my phpunit.xml).

However I keep on getting this error (even if I so much as run this command):

php artisan --env=testing  migrate

I get this error:

SQLSTATE[HY000]: General error: 1 cannot rollback - no transaction is active (SQL: rollback)

I searched online and found that this may have to do with sqlite opening many connections at the same time and not closing them first. But I'm not sure how to address that problem with laravel.

Note

unlike all the hello world tutorials that talk about using sqlite, my situation is that I have an enterprise application that has hundreds of migration files, and I'm trying to introduce unit testing to the development workflow. I'm using behat for BDD and for some reason using RefreshDatabase makes it hang after running each scenario. So I'm trying to find a more lighter weight database to be able to do that.

0 likes
0 replies

Please or to participate in this conversation.