title: Knex.js postgresql database connection
body: <p>I'm having a bit of an issue &amp; this is most likely a user error. I just trying to connect my <code>Node/Express</code> application to a database using <code>Knex.js</code>. I'm using <a href="https://postgresapp.com/" rel="nofollow noreferrer">Postgres App</a>.</p>
  
  <p><code>migrations/20180618143210_item.js</code></p>
  
  <pre><code>exports.up = function (knex, Promise) {
      knex.schema.createTable('items', (table) =&gt; {
          table.increments('id').primary();
          table.string('name');
      })
  };
  
  exports.down = function (knex, Promise) {
      knex.schema.dropTable('items')
  };
  </code></pre>
  
  <p><code>knexfile.js</code></p>
  
  <pre><code>module.exports = {
  
    development: {
      client: 'postgresql',
      connection: {
        host : 'localhost',
        database: 'my_db',
        user: 'User',
        password: ''
      },
      migrations: {
        directory: __dirname + '/db/migrations'
      },
      seeds: {
        directory: __dirname + '/db/seeds/development'
      }
    },
  
    staging: {
      client: 'postgresql',
      connection: {
        database: 'my_db',
        user:     'username',
        password: 'password'
      },
      pool: {
        min: 2,
        max: 10
      },
      migrations: {
        tableName: 'knex_migrations'
      }
    },
  
    production: {
      client: 'postgresql',
      connection: {
        database: 'my_db',
        user:     'username',
        password: 'password'
      },
      pool: {
        min: 2,
        max: 10
      },
      migrations: {
        tableName: 'knex_migrations'
      }
    }
  
  };
  </code></pre>
  
  <p>When I run <code>knex migrate:latest</code> it creates the database and I can see the following <code>\dt</code> database tables when connected to <code>my_db</code> database: </p>
  
  <pre><code>                  List of relations
   Schema |         Name         | Type  |    Owner
  --------+----------------------+-------+-------------
   public | knex_migrations      | table | User
   public | knex_migrations_lock | table | User
  </code></pre>
  
  <p>When I <code>select * from knex_migrations;</code> I'm returned: </p>
  
  <pre><code> id |          name          | batch |       migration_time
  ----+------------------------+-------+----------------------------
    2 | 20180618143210_item.js |     1 | 2018-06-18 14:40:08.994-06
  </code></pre>
  
  <p>However, if I try to run something like <code>select * from items</code> I'm getting a <code>ERROR:  relation "items" does not exist</code> error. Am I missing something here? The same error is occuring when I try to seed the data <code>knex seed:run</code></p>
  
  <p><code>items.js</code></p>
  
  <pre><code>exports.seed = function(knex, Promise) {
    // Deletes ALL existing entries
    return knex('items').del()
      .then(function () {
        // Inserts seed entries
        return knex('items').insert([
          {id: 1, name: 'rowValue1'},
          {id: 2, name: 'rowValue2'},
          {id: 3, name: 'rowValue3'}
        ]);
      });
  };
  </code></pre>
  
  <p>Error: <code>error: relation "items" does not exist</code>.</p>