Skip to content

Conversation

@rolftimmermans
Copy link

Disconnecting all connections before attempting to drop the database solves a very common and annoying issue for me, where open connections created by the Rails application are still present when attempting to drop the test database.

It manifests itself as:

dropdb: error: database removal failed: ERROR:  database "rails-app-test" is being accessed by other users
DETAIL:  There is 1 other session using the database.
Couldn't drop database for environment test
createdb: error: database creation failed: ERROR:  database "rails-app-test" already exists
Could not create database for test.

This change fixes the problem.

Disconnecting all connections before attempting to drop the database solves a very common and annoying issue for me, where open connections created by the Rails application are still present when attempting to drop the test database.

It manifests itself as:
```
dropdb: error: database removal failed: ERROR:  database "rails-app-test" is being accessed by other users
DETAIL:  There is 1 other session using the database.
Couldn't drop database for environment test
createdb: error: database creation failed: ERROR:  database "rails-app-test" already exists
Could not create database for test.
```

This change fixes the problem.
@JonathanTron
Copy link
Member

Hi @rolftimmermans, thanks for the PR, it's a good idea. I'll merge it and see why the tests are failing.

@JonathanTron JonathanTron merged commit 56e0019 into TalentBox:master Mar 6, 2025
11 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants