Create database in Heroku

To create a new database in Heroku, the procedure is as follows:

1) With your favorite browser, connect to the site: www.heroku.com and click on the " Login in ". Once you have entered your credentials, you enter your " dashboard " where you will see the web app created at previous step . Click on the name of the app:

2) Click on the " Resources " tab, then click on the " Find more add-ons " button

3) Scroll through the list of add-ons until you find " Heroku Postgres ". Postgres is the type of database we're going to create. We choose this and not a MySQL database because it is the only one completely free on Heroku:

4) By clicking on the " Heroku Postgres " add-on, the following page is displayed. Click on the "Install Heroku Postgres" button:

5) The next page allows you to select which app to associate the database with. Leave the " Add-on plan " selection as " Hobby Dev - Free ". A click inside the " App to provision to " text box to bring up the drop-down list of apps, which in our case consists of only one element:

6) Select the only app, that is the one we created at previous step :

7) Finally, once the app - database association has been made, press the "Submit Order Form" button:

8) As you can see, on "Resources" we have the new database associated with the app. Now we need the database connection parameters to be able to connect it to the app, Click on "Heroku Postgres" to open it:

As you can see, the database is initially empty. The connection parameters can be found by clicking on the " Settings" tab:

Then click on the " View credential " button:

9) Make a note (copy and paste in the "notepad") of Host, Database, User, Port and Password :

10) Last step: go back to GitHub , "Sign in" if necessary, otherwise you are already logged in in your repository page. Click on the name of the repository that was created at previous step :

11) Click on the "db.conf" file:

12) The file will be opened. To write it, click on the "pencil" symbol (as shown in the figure), then enter the data copied in point 9 ( Host, Database, User, Port and Password ) bearing in mind that dbName corresponds to Database (ie the name of the database) and dbPath will be left blank:

13) Once you have finished editing the file, scroll down to the "Commit changes" section and press the " Commit changes " button;


Related topics