I am learning ruby on rails and heroku.
I have some questions.
Could somebody help me?
After running heroku create, the terminal is somehow connected to the repository/project in heroku. After that the developer can see logs, access database, ect. But, how can I access via terminal my completed project,which is online already, in heroku without creating the same apps and upload it again to heroku?
How can access my pg database in heroku or offline?
I saw this and try to run heroku pg:psql. it gives me hidden-atoll-4790::DATABASE=> help I try \? to see pg command but I cannot use it.
I saw this link to see pg db offline. But why cannot I access /var/lib/postgresql/9.3/main directory ? it is said that I don't have permission eventhough my account is administrator account.
1.Run heroku run rails console
Run
$ heroku apps # to see all apps created by your account
$ heroku open # to open you current project in browser (run it form root of your project)
$ heroku pg:psql DATABASE_URL # to gain access to heroku postgresql terminal, here you can run SQL queries
Refer to
CLI and Heroku PG for more info
Related
I have deployed Rails app to Heroku. App uses PostgreSQL for data management. It works fine locally. I am searching for a way to push my local PostgreSQL database to the Heroku database.
heroku pg:push command doesn't work for me. Complains about lack of local psql, which is there. So I have decided to use pgbackups add-on for this purpose. I have run pg_dump locally to create a database dump and put it into the public Dropbox folder.
When I try to pull it from heroku I get the following error:
heroku pgbackups:restore DATABASE "http://file.dump"
! An error occurred and your restore did not finish.
! Please run 'heroku logs --ps pgbackups' for details.
The problem is that heroku logs --ps pgbackups gives me nothing. I don't see any pgbackups associated logs in the Heroku log listing.
Am I doing something wrong? Do I need to turn on heroku add-on logs somehow?
P.S. I am able to run heroku pgbackups:capture and heroku pgbackups:restore, but I don't see any logs either.
So I would like to make an user to admin in the app I have on heroku. When developing my app I can do it via rails c or I just open up the database file with some SQL viewer. But how can I do it for heroku?
To run the rails console in heroku, you have to use heroku run rails console (assuming you have the heroku toolbelt installed).
See https://devcenter.heroku.com/articles/getting-started-with-rails3#console or https://devcenter.heroku.com/articles/getting-started-with-rails4#console
I'm currently evaluating Nitrous.io and liking what I'm seeing so far. I've currently got a few databases for testing and development running on Heroku's hosted Postgresql service as well. I'm running into some issues when running tests though, and I'm hoping somewhere here may have a solution.
When I run rake db:test:prepare I'm getting the error:
FATAL: permission denied for database "postgres"
DETAIL: User does not have CONNECT privilege.
From what I've read elsewhere, that's trying to DROP the database, but Heroku's hosted databases don't allow that. Does anyone out there know how to run Rails tests on Heroku's Postgresql?
Nitrous.IO has released a package manager which will allow you to install Postgres within your Nitrous box. This can be used for your test database as well as your development database if needed:
https://github.com/action-io/autoparts
This also requires that you are using a Nitrous box is running version "bran" or later (see README). You may need to terminate/create a new box if you are running on version "arya".
To use autoparts, run parts search to see all of the packages available.
To install postgresql within the Nitrous box, run the following command:
parts install postgresql
Make sure that your config/database.yml file explicitly sets host: localhost for each database you wish to connect to, or else the pg adapter will fail to find the socket it needs to connect to.
According to the Heroku docs, you need to use "heroku pg:reset" in your rake task.
https://devcenter.heroku.com/articles/rake
I have now my rails 3.2.1 app running on Heroku.
I've tried to upload the database to mongohq via the heroku mongo:push command, after installing the heroku mongo plugin.
https://github.com/pedro/heroku-mongo-sync
I get the message asking me to confirm if I want to push, but once the push is done, there is nothing my db.
I'm not sure if it is a problem with heroku or if i'm missing a step.
Could it be that i need to put my app in production mode and migrate the database to production?
I'm not sure how to do that either.
Cheers
does your local heroku connection conform to the plugins assumptions [in the readme's config section]? if not you'll have to set it via:
export MONGO_URL = mongodb://user:pass#localhost:1234/db
i'll also note, that even after doing this i had to uninstall the heroku plugin and reinstall it from this fork: http://github.com/fjg/heroku-mongo-sync.git
heroku plugins:install http://github.com/fjg/heroku-mongo-sync.git
Check out the MongoSync Ruby Gem
It's a gem I wrote for that very purpose when I had to constantly copy my Local MongoDB database to and from my Production DB for a Project (I know it's stupid). It's extremely easy to use. Once you've entered your DB details in the mongo_sync.yml file, you can push and pull DBs using these rake tasks:
$ rake mongo_sync:push # Push DB to Remote
$ rake mongo_sync:pull # Pull DB to Local
Note: It's also available as shell script for non-ruby apps: mongo-sync
I have a rails app up on heroku. Sometimes the server bombs out and I have to go to the console and execute heroku restart so that servers get restarted. This seems to fix the problem.
However, I am not on my machine all the time. I would like to have a team member have this capability as well.
For this to happen...what does he need to do? Does he need to first have access to the github repository so that he can push and pull code to the repository and then install heroku on his machine?
Can this be done without git hub? can he just install heroku?
He needs the Heroku gem ($ sudo gem install heroku). He needs a SSH key, and a Heroku account that takes the key ($ heroku keys:add (pathToKey)). He needs to have his account added to the Heroku project as a collaborator. And then it’s all fine, he could say $ heroku restart --app (appName).