I had this same problem and I just fixed it. The problem is probably because travis cannot create the table which in your case is members
.
You need to add the following lines in your .travis.yaml
file
before_script:
- psql -c "create database yourdbname;" -U postgres
- psql -c "create user dbusername WITH PASSWORD 'yourpassword';" -U postgres
create a script that contains the query for creating the table. mine resembles something like this.
const pg = require('pg');
const config = {
user: 'yourdbusername', // this is the db user credential
database: 'yourdb',
password: 'yourdbpass',
port: 5432,
max: 10, // max number of clients in the pool
idleTimeoutMillis: 30000
};
const pool = new pg.Pool(config);
pool.on('connect', () => {
console.log('connected to the Database');
});
/**
* Create Tables
*/
const createTables = () => {
const queryText = `your query`;
pool
.query(queryText)
.then(res => {
console.log(res);
pool.end();
})
.catch(err => {
console.log(err);
pool.end();
});
};
pool.on('remove', () => {
console.log('client removed');
process.exit(0);
});
module.exports = {
createTables,
pool
};
require('make-runnable');
it will be preferable to make use of a remote database like elephantSQL or any other remote postgres db.
Go to your package.json
and add the following line under scripts
"create": "node ./path/to/the/file createTables",
Now update your before_script
to this
before_script:
- psql -c "create database wayfarer;" -U postgres
- psql -c "create user wayfarer WITH PASSWORD 'rrwcscrz1';" -U postgres
- "npm run create"
Also make sure you'vev installed make-runnable
and pg
packages