Does Heroku support `rails dbconsole`?

后端 未结 4 453
傲寒
傲寒 2021-02-02 10:26

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

heroku run rails dbconsole
# => Couldn\'t find database client: psq         


        
相关标签:
4条回答
  • 2021-02-02 10:49

    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.

    0 讨论(0)
  • 2021-02-02 10:51

    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."

    0 讨论(0)
  • 2021-02-02 10:57

    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.

    0 讨论(0)
  • 2021-02-02 11:01

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

    > heroku update
    0 讨论(0)
提交回复
热议问题