Rails + Postgres drop error: database is being accessed by other users

前端 未结 16 2133
时光取名叫无心
时光取名叫无心 2020-12-04 06:26

I have a rails application running over Postgres.

I have two servers: one for testing and the other for production.

Very often I need to clone the production

16条回答
  •  Happy的楠姐
    2020-12-04 06:59

    I wrote a gem called pgreset that will automatically kill connections to the database in question when you run rake db:drop (or db:reset, etc). All you have to do is add it to your Gemfile and this issue should go away. At the time of this writing it works with Rails 4 and up and has been tested on Postgres 9.x. Source code is available on github for anyone interested.

    gem 'pgreset'
    

提交回复
热议问题