- Create database 'fac9_database' locally by running postgres
CREATE DATABASE fac9_database
- Add user 'admin' and assign as the onwer of the database
CREATE USER admin WITH SUPERUSER PASSWORD 'fac9_admin'
ALTER DATABASE fac9_database OWNER TO admin
- Create db_connection.js file to create a new
Pool
of connection options - Add config.env file to export environment variables for the url and number of maximum connections of our local database
- Include config.env in the .gitignore file
- Create build_database.sql file to populate a table called people
- Create build_database.js to make SQL query to the database
- Run
node build_database.js
and check the database has been built following the steps below:
- Make sure that no errors were thrown when running the build_database.js
- Run the postgres server running
psql
- Try
SELECT * FROM people
and that should return all the columns and rows inserted in build_database.sql
- Setup basic Hapi server using five different endpoints and create getPeople.js module to make queries to our database through these endpoints.
In your application, on the command line, run heroku config:set DATABASE_URL=postgres://blah:[email protected]:5432/omg
Reference stackoverflow