Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jannevuori's avatar

SQLSTATE[HY000]: General error: 1 no such table

I've been trying to get the tests working on sqlite in memory database but I have been hitting the error 'SQLSTATE[HY000]: General error: 1 no such table'

I have cleared the config cache over and over again and the connection is defined in phpunit.xml

I am using Laravel 6.0.4 and globally installed phpunit is at version 8.3.5 PHP Version is 7.2.13 and SQLite version is 3.24.0

Any ideas?

0 likes
11 replies
Sinnbeck's avatar

Do you have this in your base test file?

use DatabaseMigrations;
11 likes
jannevuori's avatar

Yes I have.

I might be actually finally finding the reason for that. Will post soon again if this is correct.

thedejavunl's avatar

Do you have built a migration for that model? In memory databases use the migration files to create the temporary databases.

1 like
jannevuori's avatar
jannevuori
OP
Best Answer
Level 10

Found it: the problem came from one of my helper classes that accessed database and which was shared to views with View::share() and this was done in AppServiceProviders boot -method and it really was not cool place for it :)

Moved it to middleware where it can be shared only when it is really needed.

After this change the tests work again and with the sqlite :memory:

7 likes
jannevuori's avatar

Yes I had and got it already working. Thank you for your input.

waqid's avatar

Just run php artisan migrate on your root directory

4 likes
IrfanDev's avatar

@waqid This works for me! THANK YOU! The new Laravel 11.9.2 looks amazing!

1 like
MotionPhix's avatar

Simply deleting the .env file, creating another one is what worked for me

Please or to participate in this conversation.