- Deployment Steps
- Debugging
- Pushing Changes
- Changing Migrations
- Switching Heroku Environments
- Deleting Heroku Apps
- After switching to the branch you'd like to deploy, create a new branch for deployment...
$ git checkout -b deployment
- Add the following line to the bottom of your Gemfile to add the
rails_12factor
dependency to theproduction
environment...
gem 'rails_12factor', group: :production
$ bundle install
- Commit your changes.
$ git add .
$ git commit -m "added 12factor"
- Create a Heroku app using the Heroku CLI tools...
$ heroku create my-sweet-app
# wait...
$ git push heroku deployment:master
# wait some more...
The first command will both create a new app on your Heroku account and add a remote on your repository named heroku
, which points at your deployed Heroku app.
The second command will push from the local branch deployment
to the remote branch master
on the remote named heroku
.
- Run migrations and seed on Heroku...
$ heroku run rails db:migrate
$ heroku run rails db:seed
$ heroku open
Heroku automatically detects the database and creates it for you. It is up to you to finish building your application's database, however.
Errors associated with deployment will appear here. To view your app's server log...
$ heroku logs
You can also monitor the log file in your terminal session by passing the following option flag...
$ heroku logs -t
You can also view the logs in the browser via Heroku's dashboard by visiting
https://dashboard.heroku.com/apps/your-app-name/logs
$ git add .
$ git commit -m "your message"
$ git push heroku master
Note that this will not update Github. If you want to push your changes to Github as well, you need to run git push origin master
as usual.
Do not edit an existing migration file. Instead...
$ rails g migration yourMigrationName
# Edit the new migration file
$ rails db:migrate
$ git add .
$ git commit -m "added migration"
$ git push heroku master
$ heroku run rails db:migrate
$ heroku config:set RAILS_ENV=development
To change it back...
$ heroku config:set RAILS_ENV=production
$ heroku apps:delete --confirm my-sweet-app
You're likely to end up with a bunch of Heroku apps. To delete all of them at once, you can add this function to your .bash_profile
...
function happ(){
for app in $(heroku apps)
do heroku apps:delete --confirm $app
done
}
...and then in bash, run happ
from anywhere on your computer; the working directory doesn't matter.