What does heroku rake and restart commands do? - heroku

I'm using heroku for a sort time and I have some doubts on what exactly do 2 'commands'
The first is rake, I've seen here some people use it and some others, use the same instructions without rake, so I'd like to know if there's any difference in using rake or not
The other is more simple: heroku restart
Does this only affect the database or it also affect the code?
If it only affects the database, what happens to the data?
Should I use it, or it's an emergency command?
All info explained here and related to these instructions will be really helpful
Thanks!

rake is a deprecated call.
Heroku ❯ heroku help rake
Alias: rake redirects to run:rake
Usage: heroku run:rake COMMAND
WARNING: `heroku run:rake` has been deprecated. Please use `heroku run rake` instead."
Basically it is/was a shortcut to running rake calls for Rails apps.
You should use heroku run rake <task> instead.
heroku restart restarts a application processes, which are explained in more detail here: https://devcenter.heroku.com/articles/process-model
heroku help restart for more info.
heroku restart does not restart your database.

Related

How to schedule PostgreSql procedure using Heroku scheduler?

I am trying to schedule PostgreSql procedure using Heroku scheduler. I tried heroku pg:psql -c "call procedure_name();" --app app-name but gets the error from scheduler "bash: heroku: command not found"
That error is telling you important information. The Heroku CLI is not present in your environment, so bash complains that heroku isn't a command that it recognizes.
If you want to run heroku commands from your application you'll need to include the cli buildpack when you build your application to make sure it's properly bundled. Once you've included the buildpack and triggered a new build, this should work.

Reach heroku app terminal

I deployed an app onto heroku and wanted to check how can I connect to the deployed app in my terminal so I can do things like run migrations?
thanks in advance!
You can use the heroku command to create a one-off dyno to run arbitrary commands like bash or rake db:migrate.
For example heroku run bash -a my-app will run a bash shell on a one-off dyno.
Note that there is no way to directly connect to a running dyno on Heroku (e.g. via ssh); running the heroku run command will create a new temporary dyno that you can use to run commands using the deployed version of the code.

How can I use Heroku Scheluder Standard to automatize backups?

As you can say, I have an app running in Heroku, recently I installed Heroku Scheluder Standard add-on to automatize heroku pgbackups:capture --expire --app my-app, but it's been 3 days and it doesn't make the backup, so…
How can I make it do them?
You may find the pgbackups addon will work for you, depending on the frequency with which you want the backups to occur. heroku addons:add pgbackups:auto-month will configure the appropriate addon.

how to setup postgres db in Heroku

I'm totally new to Heroku and Postgres and I'm trying to figure out how to setup and access the Postgres db in a Heroku Ruby app.
I'm not sure how to go about setting this up. I've found some information about using the command:
rake db:create
Where do I enter this command? I'm completely in the dark on this.
Any help with how to setup/access the Postgres db in Heroku would be greatly appreciated.
Thanks.
Without info on what type of Ruby app you're building, what gems you may be utilizing, or what frameworks you may be building on, it is impossible to completely guide you through how to connect your Ruby app to the Heroku Postgres database. But here are a few things to point you in the right direction:
Install the Heroku Toolbelt as #jordan.baucke suggested. Beyond just adding plugins, you'll be using this toolbelt for nearly every Heroku-related action. Just follow the link, download, and install. Easy!
Now that you have the toolbelt, login to your account from the command line: heroku login.
Now make your app. While in your app folder (on the command line), execute: heroku apps:create <app name> -s cedar.
Now add the Postgres db: heroku addons:add heroku-postgresql:dev -a <app name>
From Ruby, you can connect to the db through the environment variable: ENV['DATABASE_URL'].
Deploy the app via git: git push heroku master.
From here, we really can't give you any further guidance since we don't know how you're interfacing with Postgres. But the above steps should at least get you to be able to connect to the db from your Heroku app.
For starters, are you using the the Heroku toolbelt? (command line tools?)
You can do it from the website as well, but with the toolbelt, you can enter heroku addons:add heroku-postgresql:dev --app *your app name*
Heroku will automatically inject the database into your app's database.yml when you deploy your app into Heroku.
Finally, you need to migrate the production database to your current migrations. You can do this remotely with the toolbelt again:
$ heroku run rake db:migrate
This will remotely connect a console and pull your migrations into your production database on the server.

Displaying a confirmation after entering a Heroku command?

I am using Heroku and normally I do commands like:
heroku run rake db:reset --app myapp
which resets my database. I have read online that Heroku didn't support all rake commands (including db:reset, but the article may be outdated? as it works fine for me)
However, I have a production app and a staging app and am concerned about my late night programming, with regards to an accidental hit of db:reset on my production app.
Is there a way i could implement a prevention confirmation with a command like:
heroku run rake db:reset --app myapp or heroku run rake db:migrate --app myapp
or
git push production?
Be very careful when running any destructive commands. Just incase use https://devcenter.heroku.com/articles/pgbackups to make sure you can recover data if you do accidentally drop the database.

Resources