Create a heroku user by going to heroku.com
- Now create a new app
- Give the app a good name and choose Europe as the region
Lets set our new app so that everytime we push code to master, that code is deployed to our website.
- Choose Github for deployment method
- Choose the
masterbranch on yourmeal-sharingrepo and clickEnable Automatic Deploys
The database we have used so far is the local one running in Mysql Workbench. Now we will add a database in the cloud.
- Under
ResourcesclickFind more add-ons
- Add clear
ClearDB MySQL. Congratulations we now have a database in the cloud. Now we just need to connect it to our app. - Like we have out
.envfile locally that referes to the environment variables in herkou we have to add them manually:
- Go to
Settings. ClickReveal Config Vars. It will have the format of:mysql://{user}:{pass}@{host}/{database} - Exactly like the
.envfile add the same environment variables. TheDB_PORTshould be 3306.
Now the database is connected to the app 🎉
BUT the database has no tables! Connect to the ClearDB database using Mysql Workbench and create the tables in workbench just like you have with the local database.
We should now have connected the database (with the newly inserted tables) to our application. Try and go to the app's webpage and see if it works.
If there is an error, use this command: heroku logs --tail --app app-name - substitute app-name with the actual app name. TO install it go here
Remember to add the link to the deployed website in the readme.md file (of the meal-sharing repo) where it says: Link to deployed website: