Heroku

Commands

$ git push prod

How to upgrade to new version of Rails

Create new Gem set
$ rvm list known
$ rvm install 2.0.0
$ rvm gemset list
$ rvm use 2.0.0
$ rvm gemset create rails4
$ gem install rails –version 4.0.0

Create new Rails4 app deploy to Heroku
$ rails new myapp
$ cd myapp

Add the following to gem file:

ruby '2.0.0'

group :development, :test do
   gem 'sqlite3'
end
group :production do
  gem 'pg'
  gem 'rails_12factor'
end

$ rails generate scaffold User name:string
$ bundle exec rake db:migrate
Test locally
$ rails s -p 3001
$ git init
$ git add .
$ git commit -m “init”
$ heroku create
$ git push heroku master
$ heroku run rake db:migrate
$ heroku open

Database

Pull database locally
$ heroku pgbackups
$ heroku db:pull

Database backup/restore
$ heroku addons:add pgbackups
$ heroku pgbackups:capture
$ heroku pgbackups:restore DATABASE b002
$ heroku pgbackups:destroy b001

Reset database
$ git push heroku
$ heroku pg:reset DATABASE
$ heroku run rake db:migrate
$ heroku run rake db:populate

Migrations not working
$ heroku restart
$ heroku ps –app targetapp (list dynos)
$ heroku ps:restart web.1 –app targetapp

Setup automonth backups
$ heroku pgbackups
$ heroku addons:upgrade pgbackups:auto-month

SQL changes to prod

1. Pull database local
$ heroku db:pull

2. Make changes in prod.rake
3. Test and run locally
$ bundle exec rake db:updateprod

4. Checkin.
5. Push to prod.

6. Run against prod
$ heroku run rake db:updateprod

Environment vars

$ heroku config:set S3_BUCKET=agilenutshell –app targetapp
$ heroku config –app hidden-ridge-8790

Loggin

$ heroku logs –tail –app hidden-ridge-8790

Routes

Adding/removing routes
$ git remote -v
$ git remote rm heroku
$ git remote add heroku get@heroku.com:takemystuff.git

Creating new route

If you have blown away your repo and you need to add your heroku remote instance back do this:

$ heroku create
$ git remote set-url heroku git@heroku.com:hidden-ridge-8790.git

This creates the heroku remote, and then points it to where you want

Pushing to heroku for first time

$ heroku create –stack cedar
$ git push heroku master
$ heroku run rake db:migrate

Mapping git remote back to an existing url

$ git remote add heroku git@heroku.com:hidden-ridge-8790.git

Misc commands

$ heroku run rake db:migrate (–app targetapp)
$ heroku logs (–app targetapp –tail)
$ heroku open
$ heroku run console
$ heroku domains:add academy.robotsandpencils.com
$ heroku info -a secret-waters-xxxx

How to create a staging environment
https://agilewarrior.wordpress.com/2014/05/16/how-to-create-a-staging-environment-heroku/

How to create a named app
https://agilewarrior.wordpress.com/2014/05/16/how-to-create-a-named-app-in-heroku/

Images not showing up
http://stackoverflow.com/questions/21974190/background-image-not-showing-up-in-heroku

1 Comment (+add yours?)

  1. How to add a git remote to a heroku app | The Agile Warrior
    Aug 02, 2013 @ 18:10:12

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: