Setting up your Heroku site with JawsDB using Sequel Pro
Tags: heroku, sequelpro, sql, deploy
Published: 2019-06-11 23:50:22

---
title: Setting up your Heroku site with JawsDB using Sequel Pro
published: true
description: Step-by-step walk through for setting up SQL for deployment!
tags: heroku, sequel Pro, SQL, deploy
cover_image: https://thepracticaldev.s3.amazonaws.com/i/4baojlk0p0mc6eu3hpx1.jpeg
---

I found a few posts here and there online that helped fix one error or the other, but didn’t completely walk me through this process. I got errors like this in my logs: 

![](https://thepracticaldev.s3.amazonaws.com/i/4kiza9r6e7zrtze40ynb.png)

Hope this helps!

1- First things first: Push all your code to your github repo. Once there type:

```javascript
heroku create
```

to create your heroku connection in the command-line. Log on to heroku in your browser and head to your new app’s page.

2- Click on the “Resources” tab and find the area under “Add-ons”.

![](https://thepracticaldev.s3.amazonaws.com/i/rp4ss7uiuomckub4qjh1.png)

3- Start typing “JawsDB” in the input box and a list of results should appear like below:

![](https://thepracticaldev.s3.amazonaws.com/i/rlhzcatgpgm4ngfadppi.png)

Select “JawsDB MySQL” to connect to your app. A pop-up will be displayed giving you plan options. Select the “Kitefin” (free version) and click “Provision”

![](https://thepracticaldev.s3.amazonaws.com/i/39jqemglbgn144au6bby.png)

Once it’s successfully added on, it’ll be listed on your Resources page. Go ahead and click on it. This will lead you to the settings page of your JawsDB in a separate tab.

![](https://thepracticaldev.s3.amazonaws.com/i/3j97vo1ou54ti36x8o12.png)

![](https://thepracticaldev.s3.amazonaws.com/i/4g3l80nrhe5oyn3mjse0.png)

4- Let’s head into Sequel Pro. You will need to create a new connection. Make sure you are creating a “Standard” connection. In this step, you will need to copy and paste “Host”, “Username”, and “Password” values from your JawsDB Settings (image above) *EXACTLY* into your Sequel Pro Connection values (image below) and click “Connect”.

![](https://thepracticaldev.s3.amazonaws.com/i/iy8njmlhnkglwou7v9f5.png)

5- Under your “Choose Database” dropdown menu, select the database listed under random letters.

![](https://thepracticaldev.s3.amazonaws.com/i/i7euslhbgxr4duhfghgd.png)

In your “Query” tab, Create your schema. Make sure the id, createdAt, and PRIMARY KEY are listed exactly as below and run it.

![](https://thepracticaldev.s3.amazonaws.com/i/i4nh9vhqinhtou3bxple.png)

6- Under your “Structure” tab, edit the “Default” value to display “CURRENT_TIMESTAMP”. Edit the “Extra” value from the dropdown menu to display “on update CURRENT_TIMESTAMP”. (image below)

![](https://thepracticaldev.s3.amazonaws.com/i/cz5fqnjwbrrazrkrced3.png)

7- Let’s head into your ‘connection.js’ file and alter it a little. Make sure to include your “port” in this section. Accidentally leaving this out was a cause of a few of my errors.

```javascript
// Set up MySQL connection.
var mysql = require("mysql");
var connection;
//make connection
if (process.env.JAWSDB_URL){
  connection = mysql.createConnection(process.env.JAWSDB_URL);
}else{
  connection = mysql.createConnection({
    port: 3306,
    host: "localhost",
    user: "root",
    password: "",
    database: "burgers_db"
  })
}
connection.connect();
// Export connection for our ORM to use.
module.exports = connection;
```

8- Let’s head into your ‘server.js’ file and alter the port variable. Adding the “process.env.PORT” allows access to the database.

```javascript
var port = process.env.PORT || 3000;
```

9- Make sure to push all your changes to your github repo. Once successful and completed, push to heroku.

```javascript
git push heroku master
```
That should finalize everything and connect your mySQL Database to your heroku app. If you come across any errors, always make sure to look at your logs.

For a live example of this, you can checkout the github repo of my project: https://github.com/laurengranada/week-14-burger

Good luck!