Manual testing (for heroku-24-stack) with a Ruby-on-Rails app
-
Create an app:
heroku create --remote heroku-24 --stack heroku-24 <your app name>-heroku-24- creating an app:
<your app name>-heroku-24; let us call it<your-app-24>
- creating an app:
-
Associate the add-ons that are associated with your current one
-
Copy all config values to the heroku-24 app
heroku config --shell --remote herokulists all config values of your existing app. Although they can be copy-pasted to the setting command, be careful about the quotes! You may end up including extra quotes in the values set.- Check out with
heroku config --shell --remote heroku24
-
Foc CLI, you should add an option of either
--remote heroku-24or--app <your-app-24>to work on the new (test) stack. Some tasks accept both, but some do only--app.- Also, when you work on your existing stack, you now must specify
--app(or--remote), while the new stack is alive.
- Also, when you work on your existing stack, you now must specify
-
Modify your app according to heroku-24
- Make sure you are on
mainbranch:git status; git branch - The branch must be
main(!) (ormaster(?)) according to Heroku's policy. - Therefore, unless you prepare a dedicated separate development environment for the new stack, you basically must share the Git branch with your existing one. This means that you should avoid updating the existing app while tweaking your app for heroku-24; instead, you should do testing and migration to upgrade to the new stack in one go.
- In the app code, you must at least change the database configuration (i.e., database name, user name, password) in your app (in particular, the DB password is not fixed on heroku and is taken from a dedicated environmenal variable), so you must edit the file for
heroku-24). See the next item.
- Make sure you are on
-
As for the database, you can view all the necessary parameters on your Dashboard on Heroku Dashboard.
- For Rails, you simply copy & paste the database name, user name, and password on
config/database.yml. Plain text is fine (but you may well use a pair of single quotations). heroku pg:psql --remote heroku-24may work straightaway.- Your Heroku Dashboard may provide a direct access CLI (I don't remember).
- Alternatively, once you have pushed your app, as long as the build have been completed successfully and you have successfully created a DB (even if the app fails to start due to the lack of initial seeded data), you can run
heroku db --app <your-app-24>; note that you are probably asked to type the DB password, which you can obtain from the dashboard.
- For Rails, you simply copy & paste the database name, user name, and password on
-
Push Git to the new
heroku-24repository
git push heroku-24 main- Here, the branch must be
main - I'd recommend you to open
heroku logs --app <your-app-24> --tailin a separate terminal before git-push so that you can get the full log while you are performinggit push, partly because the app is unlikely to start before the initial migrations and seeding have been made, so a long series of backtrace for the error is likely. The full backtrace provides critical information for debugging of your app. - Check whether the build has been successful.
- Here, the branch must be
-
You may need more than one commit in the
mainbranch of your Git repositories (both local andheroku-24)- This is fine, as long as you don't modify the exiting remote app.
-
Once the build has been succesful, run this to see if it launches successfully:
heroku run --app <your-app-24> rails console -
Upon success, make the db, migrate, and seed it:
heroku run --app <your-app-24> db:createheroku run --app <your-app-24> db:migrate- Note that
heroku run --app <your-app-24> db:migrate:statusmay not work at this stage! Still,db:migratewould succeed. 3heroku run --app <your-app-24> db:migrate:statusshould now work, once the first migration has been made, even if the migrations process fails at a later stage.
- Note that
heroku run --app <your-app-24> db:seed- Check the status with
heroku run --app <your-app-24> rails console
-
Just in case, run
heroku ps:restart --app <your-app-24> -
Check at the website with
heroku open --app <your-app-24>- The access URL should be listed on your dashboard on heroku
-
Once you have confirmed that your new app should work on the new stack
heroku-24, remove your app from the test stack withheroku apps:destroy --remote heroku-24
-
Suppose you have made some changes in the
mainbrach of your local Git repository to make your app be accommodated in the new stack (which basically needs a fresh installing). Now you should backport the changes to your existing app (perhaps before migration to the new stackheroku-24)- A strategy is to commit the
mainbranch without the temporary modification for theheroku-24DB (inconfig/database.yml) andgit rebaseto delete the changed contents inconfig/database.yml. They will kind of remain only in the remote server ofheroku-24, which is never a problem. In fact, those database parameters are all temporary, and so even if they are leaked, they won't be a security threat in practice. Still, it would be nice not to clatter your repository, be it local or different remote repository like Github. - In
git rebase, specify the last commit number, which is pushed to your existing heroku repository. - For examlpe, suppose the commits are like:
Ax - Bx - Cx (last-commit-to-push-to-existing) - Dx - Ex - Fx (pushed-to-heroku-24)
Then, rungit rebase -i Cx(NOTE: NOTDx) - Don't forget to amend the date immediately:
git commit --amend --no-edit --date=now
Or this may work:git rebase --ignore-date HEAD - Check it with
git log -n 15 --graph --decorate --pretty=oneline --abbrev-commit --all git push heroku maingit status
- A strategy is to commit the
-
Execute preparatory migration to
heroku-24:heroku stack:set heroku-24 -a $my_appname
-
Migration takes effect only after the first Git commit. Do it:
heroku maintenance:on -a $my_appnamegit commit --allow-empty -m "Upgrading to heroku-24"git push heroku main
-
Check if deployment is successful as usual (Notice no necessity of the app name):
% heroku status % !her:0 ps % !her:0 logs --tail [^C] % !her:0 open % !her:0 maintenance:off -a $my_appname % !her:0 logs --tail [^C] % !her:0 run rails console