Peter Nixey
Peter Nixey

Reputation: 16555

Does Heroku support `rails dbconsole`?

I'm trying to fire up rails dbconsole on Heroku but get the following error:

heroku run rails dbconsole
# => Couldn't find database client: psql. Check your $PATH and try again

Is it possible to use the dbconsole on Heroku? If not is there another client that can be used?

Upvotes: 24

Views: 8890

Answers (4)

oklas
oklas

Reputation: 8220

Is it possible to use the dbconsole on Heroku? If not is there another client that can be used?

You can use online database client if you use activeadmin.

Just add the gem activeadmin-sqlpage:

gem 'activeadmin-sqlpage'

And create activeadmin page:

# file app/admin/sql.rb
ActiveAdmin::SqlPage::register

Restart your server. Then go to admin panel and navigate the menu SQL. Enter any sql command and press Ctrl+Enter or Submit button.

Upvotes: 0

konyak
konyak

Reputation: 11716

https://devcenter.heroku.com/articles/heroku-postgresql - "You must have PostgreSQL installed on your system to use heroku pg:psql". So maybe you're missing PostgreSQL on your machine. If that's not the case, then try this other command to get to the Postgres console instead:

heroku pg:psql 

"psql is the native PostgreSQL interactive terminal and is used to execute queries and issue commands to the connected database."

Upvotes: 47

Luke Girvin
Luke Girvin

Reputation: 13442

I think heroku-sql-console should provide similar functionality, but when I tried running it I got this error:

undefined local variable or method `app' for # (NameError)

It's been reported as a bug but there's no fix or workaround.

Update: As @Alban suggests, the fix to this problem is to update the client. I had to run gem update heroku to do this.

Upvotes: 8

Alban
Alban

Reputation: 1943

As Luke says, you may use heroku-sql-console. But first make sure you are using the latest heroku client:

> heroku update

Upvotes: 3

Related Questions