Skip to content

Instantly share code, notes, and snippets.

@tphdev
Created October 11, 2018 01:04

Revisions

  1. tphdev created this gist Oct 11, 2018.
    42 changes: 42 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,42 @@
    1) Create Heroku Account
    - https://signup.heroku.com/dc

    2) Install Heroku CLI
    - https://devcenter.heroku.com/articles/heroku-cli#download-and-install

    3) Create Heroku App
    - heroku create «your app name»
    - check `heroku -v`

    4) Create Postgres database for app
    - `add-on- heroku addons:create heroku-postgresql:hobby-dev`

    5) Deploy Heroku App

    6) Additional Steps
    - `knexfile.js`
    ```js
    // ...

    const productionConfig = Object.assign(
    {},
    devConfig,
    { connection: process.env.DATABASE_URL }
    )

    module.exports = process.env.NODE_ENV === 'production' ? productionConfig : devConfig
    ```

    - `server.js`
    ```js
    const PORT = process.env.NODE_ENV === 'production' ? process.env.PORT : 3000
    //....
    const appDb = knex( dbConfigObj )
    ```

    7) Migrations + Seeds
    ```
    heroku run knex migrae:latest

    heroku run knex seed:run
    ```