Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#166109412 Read database name as an environment variable #39

Merged
merged 2 commits into from
May 20, 2019

Conversation

chidimo
Copy link
Owner

@chidimo chidimo commented May 20, 2019

What does this PR do?

Update database name settings

Description of Task to be completed?

  1. Read database name from environment variables.
  2. This lets us set the database to use on Heroku

How should this be manually tested?

  1. Clone the repo
  2. cd into the root folder on a cmd shell and run yarn install. PowerShell is fine also.
  3. Setup a PostgreSQL DB.
  4. Define a .env file in the root of the project and supply values for the following parameters
    JWT_SECRET=<json-web-token-secret>
    DBNAME=<database-name>
    PGPASSWORD=<postgres-db-password>
    PGHOST=<postgres-db-host>
    PGUSER=<postgres-db-user>
    PGPORT=<postgres-db-port>
  5. Create a PostgreSQL database called testdb.
  6. Create the database tables listed below.
  7. Now run the tests with yarn test
CREATE TABLE users (
	id SERIAL PRIMARY KEY,
	email VARCHAR NOT NULL UNIQUE,
    password VARCHAR NOT NULL,
    firstname VARCHAR DEFAULT '',
    lastname VARCHAR DEFAULT '',
    phone VARCHAR DEFAULT '',
    photo VARCHAR NULL,
    address jsonb DEFAULT '{"home": "", "office": ""}',
    status VARCHAR DEFAULT 'unverified',
    isAdmin BOOLEAN DEFAULT false
);

CREATE TABLE IF NOT EXISTS loans (
	id SERIAL PRIMARY KEY,
	userid INT NOT NULL,
    createdon TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
    status VARCHAR DEFAULT 'pending',
    repaid BOOLEAN DEFAULT false,
    amount FLOAT NOT NULL,
    tenor INT NOT NULL,
    interest FLOAT NOT NULL,
    balance FLOAT NOT NULL,
    paymentinstallment FLOAT NOT NULL
);

CREATE TABLE IF NOT EXISTS repayments (
    id SERIAL PRIMARY KEY,
    loanid INT NOT NULL,
    adminid INT NOT NULL,
    createdon TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
    amount FLOAT NOT NULL
)
  1. Now run command yarn test

Any background context you want to provide?

Be sure to set up the database as instructed above

What are the relevant pivotal tracker stories?

166109412

Screenshots (if appropriate)

Nil

Questions:

Nil

This is done so that the database name can be passed to heroku as
an env var
[Finishes #166109412]
@chidimo chidimo merged commit 418043e into develop May 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant