How do I enable Rails to support multiple connections open to the database?

0

I use PostgreSQL in my API and if my GUI (Navicat) is open accessing the application database and try to run the command db:drop db:create db:migrate db:seed I get the error below:

ActiveRecord::StatementInvalid: PG::ObjectInUse: ERROR:  database "platform_development" is being accessed by other users

Only with the GUI (Navicat) closed can I carry out the command. Is it possible to enable support for multiple concurrent connections without having to close the GUI?

    
asked by anonymous 03.01.2017 / 12:00

1 answer

0

The problem is with PostgreSQL!

To resolve, you need to end the connection before creating a new one. Fortunately, you can create a task for this and invoke connection closure through triggers in Rails.

While not a complex task to do manually, gem pgreset encapsulates the required logic, making simple addition of this feature:

group :development, :test do
  ...
  gem 'pgreset', '~> 0.1.1'
end

This is done by having the GUI (Navicat) open while you run the command db:drop db:create db:migrate db:seed .

    
03.01.2017 / 14:33