Blog · Articles tagged with "postgres" · show all articles »

How to drop your Postgres database with Rails 4

Update September 28 2016: There is now a gem that you can include in your app to use the technique detailed below.

When you use Postgres as your database with Rails and try to drop your database using rake db:drop, you might run into this annoying error:

PG::ObjectInUse: ERROR:  database "myapp_development" is being accessed by other users
DETAIL:  There is 1 other session using the database.
: DROP DATABASE IF EXISTS "myapp_development"
Read on