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

russellxu's avatar

Phpunit is adding prefix on db name while running migrations

laravel vresion: 12.0.1

php version: 8.4

pest version: 3.7.4

When I first run test in an empty database,it won't cause any problem. But if RefreshDatabase or LazilyRefreshDatabase is added in TestCase, the second time running test is gonna cause an error, because it somehow add prefix not only on the table, but also on database name while migrating database. My actual db name is campus_testing, phpunit is trying to migrate tables on db x_campus_campus_testing since my prefix config on app\database.php is set to x_campus_. Still trying to find a solution....

1 like
1 reply
russellxu's avatar
russellxu
OP
Best Answer
Level 23

Finnally I figure it out: I update laravel framework from 11 to 12,but never update other packages, I run composer update, and everything works fine as expcted. Some old version of those packages must be the reason cause problems.

Please or to participate in this conversation.