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

Asked

Viewed 39 times

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 get the error below:

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

Only with the closed GUI (Navicat) can I execute the command. It is possible to enable support for multiple simultaneous connections without having to close the GUI?

1 answer

0


The problem is in Postgresql!

To resolve it is necessary to terminate the connection before creating a new one. Fortunately it is possible to create a task to do so and invoke connection closure via triggers in Rails.

Although it is not a complex task to do manually, the Gem pgreset encapsulates the necessary logic, making it simple to add this resource:

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

Once this is done you can have the GUI (Navicat) open while you run the command db:drop db:create db:migrate db:seed.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.