Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Deploying to Heroku with PSQL

This walkthrough assumes that you understand how make a simple express APP with a single route. This app has db base called usersTest with one table for users. The users table has two columns, name and id.

If you need a head start when it comes to creating an express app, check this repo to get you started.

Make sure you're logged in to your heroku account first.

Heroku APP


  • Create a Heroku app using the following command:

    	$ 	heroku create
  • Deploy your app using the following command:

     	$ 	git push heroku master
  • To display the log for heroku, you have this command:

     	$  heroku logs --tail

But, wait … what about the database mentioned?

The data base you create on your laptop, does in fact exist on your laptop, heroku doesn't know a thing about it, because that database is for development environment and it strictly for development and Heroku's environment is for production. What does that mean? It means we need to head to our knexfile.js and head to the production objection and fix/add something there. Here is the current production object:

	production: {
    client: 'postgresql',
    connection: {
      database: 'my_db',
      user:     'username',
      password: 'password'

We need to have a production environment database that we can reference to in production connection database key. How do we get to create db with our heroku app? Here is how:

	$ heroku addons:create heroku-postgresql:hobby-dev

This creates a database for your app. But how do I access this database? Type this command:

	$ heroku config

You'll get something similar:


See that DATABASE_URL? That's a link to your production environment that was create for by heroku after the previous command. Copy that URL and head to your knexfile.js, to production object and paste the url to database connection key.

Make sure you push your changes to your master, then deploy the changes to heroku like you did before. Open your heroku app.

  • To create run the migrations that you have created, you need to run them for heroku using the command:

     	$ heroku run knex migrate:latest
  • You need to run that command whenever you have some new migration.


No description, website, or topics provided.






No releases published


No packages published