I can't seem to reset my database while using docker compose. I've tried killing the server, killing just the database, and restarting the machine.
Anyone know the best way to clear out the development database?
Here's what I tried:
docker-compose run web rake db:reset
I am getting this error:
PG::ObjectInUse: ERROR: cannot drop the currently open database : DROP DATABASE IF EXISTS "postgres" Couldn't drop database 'postgres' rake aborted!
I'm using the setup exactly as described by the docker-compose quickstart: https://docs.docker.com/compose/rails/
I have a rails container and a postgres container
You are using the wrong database.
The database postgres
is normally not used for user data, but for administrative purposes. For example, if you want to drop a database, you have to be connected to a different database in the PostgreSQL database cluster to issue the SQL statement DROP DATABASE
. Normally, the database postgres
is used for that purpose, and I have no doubt that Docker does exactly that when it tries to drop a database.
If you really want to drop the database postgres
, you'd have to connect to some other database in the cluster. The correct solution, however, is to keep your data in a different database. Then the problem should go away by itself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With