foundry
foundry copied to clipboard
Database not resetting and throws error in CI
In my CI environment (Gitlab) when I run my tests, I get the following error:
RuntimeException: Error running "doctrine:database:drop": Could not drop database "postgres" for connection named default
An exception occurred while executing 'DROP DATABASE "postgres"':
SQLSTATE[55006]: Object in use: 7 ERROR: cannot drop the currently open database
I'm using PostgreSQL 12. Not sure how to get around this.
Advice appreciated!
Hey @dugajean, as you can see in #51, I've been having trouble getting this library's test suite working with PostgreSQL.
Are you using DAMADoctrineTestBundle by chance?
@kbond No I don't use that.
I didn't check the source code of Foundry and how this could be implemented, but Postgres allows you to unlock the db which gives you the power to drop it. I may have a look, but it would be great if you could point me in a direction to speed things up.
Thanks for this great package!
Damn, that was the problem with #51. I'm at a loss here... I've never used postgres so I'm not sure what's causing the problem.
One thing you could try is creating the database/schema manually before your test suite is run and disabling the drop/create in foundry by setting this env var: FOUNDRY_DISABLE_DATABASE_RESET=1. The schema will still be dropped/created before each test.
@dugajean, did the above work for you (FOUNDRY_DISABLE_DATABASE_RESET=1)?
Closing as stale. Feel free to ping me to reopen if desired.
Hello @kbond
we're trying to use foundry with dama & postgre here, and we have the same error, with (and without) the env var FOUNDRY_DISABLE_DATABASE_RESET
Could not drop database "app_test" for connection named default
An exception occurred while executing a query: SQLSTATE[55006]: Object in use: 7 ERROR: database "app_test" is being accessed by other users
DETAIL: There is 1 other session using the database.
I'm closing this, because the problem no longer occurs.