title: How to create a real live database in Travis CI with a Node.js app?
body: <p>I have an <a href="https://github.com/chaim1221/Navaja-API/tree/develop" rel="nofollow noreferrer">open source project</a> that uses Node.js, Knex.js, PostgreSQL, and Travis CI. I'm currently writing integration tests to test the database connection and implement the repository pattern. My tests will not run on Travis CI.</p>
  
  <p>This problem is briefly addressed in the <a href="http://docs.travis-ci.com/user/database-setup/#PostgreSQL" rel="nofollow noreferrer">documentation</a>, but my scenario requires that specific tables exist in order for my tests to run. My <a href="https://github.com/chaim1221/Navaja-SQL" rel="nofollow noreferrer">database project</a> will create itself with the <code>node app.js</code> command. I've tested this locally as a dependency; <code>npm</code> installs the dependency without errors and the database gets created.</p>
  
  <p>However, despite the script successfully running on Travis CI (<a href="https://github.com/chaim1221/Navaja-API/blob/develop/.travis.yml" rel="nofollow noreferrer">here</a> is my <code>.travis.yml</code>), <code>mocha</code> (by way of <code>npm test</code>) goes on to say that it cannot find the user I created.</p>
  
  <p><a href="https://i.stack.imgur.com/ESitX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ESitX.png" alt="success_failure"></a></p>
  
  <p>I've followed the steps outlined in <a href="https://stackoverflow.com/questions/8394266/travis-ci-fatal-role-does-not-exist">this SO question</a>, to no avail. Travis CI seems to ignore the <code>config/database.yml</code> file and it has no effect.</p>
  
  <p>Will anyone familiar with this CI process please help? I really want to get the database pipeline up and running. I'd prefer to avoid <a href="https://stackoverflow.com/a/32020336/2496266">running Travis CI locally</a> because I just don't think it's necessary. There should be a way to tell Travis CI to create the database user, the database, and keep the connection alive long enough to run the integration tests.</p>