meteor/postgres-packages

No such table

Closed this issue · 6 comments

=> Started proxy.                             
I20151008-16:54:17.319(8)? Item = [object Object]
W20151008-16:54:17.325(8)? (STDERR) 
W20151008-16:54:17.326(8)? (STDERR) /home/spsy/.meteor/packages/meteor-tool/.1.1.9.ltydx3++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:245
W20151008-16:54:17.327(8)? (STDERR)                         throw(ex);
W20151008-16:54:17.327(8)? (STDERR)                               ^
W20151008-16:54:17.328(8)? (STDERR) Error: PG: no such table
W20151008-16:54:17.329(8)? (STDERR)     at [object Object].Table (collection.js:48:15)
W20151008-16:54:17.329(8)? (STDERR)     at lib/init.js:3:9
W20151008-16:54:17.329(8)? (STDERR)     at /home/s/src/my/meteor/leaderboard2/.meteor/local/build/programs/server/app/lib/init.js:14:4
W20151008-16:54:17.329(8)? (STDERR)     at /home/s/src/my/meteor/leaderboard2/.meteor/local/build/programs/server/boot.js:242:10
W20151008-16:54:17.330(8)? (STDERR)     at Array.forEach (native)
W20151008-16:54:17.330(8)? (STDERR)     at Function._.each._.forEach (/home/spsy/.meteor/packages/meteor-tool/.1.1.9.ltydx3++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
W20151008-16:54:17.331(8)? (STDERR)     at /home/s/src/my/meteor/leaderboard2/.meteor/local/build/programs/server/boot.js:137:5
=> Exited with code: 8
I20151008-16:54:29.653(8)? Item = [object Object]
W20151008-16:54:29.707(8)? (STDERR) 
W20151008-16:54:29.708(8)? (STDERR) /home/spsy/.meteor/packages/meteor-tool/.1.1.9.ltydx3++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:245
W20151008-16:54:29.710(8)? (STDERR)                         throw(ex);
W20151008-16:54:29.716(8)? (STDERR)                               ^
W20151008-16:54:29.854(8)? (STDERR) Error: PG: no such table
W20151008-16:54:29.854(8)? (STDERR)     at [object Object].Table (collection.js:48:15)
W20151008-16:54:29.854(8)? (STDERR)     at lib/init.js:3:9
W20151008-16:54:29.855(8)? (STDERR)     at /home/s/src/my/meteor/leaderboard2/.meteor/local/build/programs/server/app/lib/init.js:14:4
W20151008-16:54:29.855(8)? (STDERR)     at /home/s/src/my/meteor/leaderboard2/.meteor/local/build/programs/server/boot.js:242:10
W20151008-16:54:29.855(8)? (STDERR)     at Array.forEach (native)
W20151008-16:54:29.855(8)? (STDERR)     at Function._.each._.forEach (/home/spsy/.meteor/packages/meteor-tool/.1.1.9.ltydx3++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
W20151008-16:54:29.856(8)? (STDERR)     at /home/s/src/my/meteor/leaderboard2/.meteor/local/build/programs/server/boot.js:137:5
=> Exited with code: 8
I20151008-16:54:41.655(8)? Item = [object Object]
W20151008-16:54:41.717(8)? (STDERR) 
W20151008-16:54:41.719(8)? (STDERR) /home/spsy/.meteor/packages/meteor-tool/.1.1.9.ltydx3++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:245
W20151008-16:54:41.722(8)? (STDERR)                         throw(ex);
W20151008-16:54:41.722(8)? (STDERR)                               ^
W20151008-16:54:41.849(8)? (STDERR) Error: PG: no such table
W20151008-16:54:41.849(8)? (STDERR)     at [object Object].Table (collection.js:48:15)
W20151008-16:54:41.850(8)? (STDERR)     at lib/init.js:3:9
W20151008-16:54:41.850(8)? (STDERR)     at /home/s/src/my/meteor/leaderboard2/.meteor/local/build/programs/server/app/lib/init.js:14:4
W20151008-16:54:41.850(8)? (STDERR)     at /home/s/src/my/meteor/leaderboard2/.meteor/local/build/programs/server/boot.js:242:10
W20151008-16:54:41.851(8)? (STDERR)     at Array.forEach (native)
W20151008-16:54:41.851(8)? (STDERR)     at Function._.each._.forEach (/home/spsy/.meteor/packages/meteor-tool/.1.1.9.ltydx3++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
W20151008-16:54:41.851(8)? (STDERR)     at /home/s/src/my/meteor/leaderboard2/.meteor/local/build/programs/server/boot.js:137:5
=> Exited with code: 8
=> Your application is crashing. Waiting for file change.

My code

console.log('Item = ' + PG);

Items = new PG.Table("items");

I have the table

todo=# \d+ items
                                                    Table "public.items"
 Column |         Type          |                     Modifiers                      | Storage  | Stats target | Description 
--------+-----------------------+----------------------------------------------------+----------+--------------+-------------
 id     | integer               | not null default nextval('items_id_seq'::regclass) | plain    |              | 
 task   | character varying(64) |                                                    | extended |              | 

.knex/knexfile.js is

// Update with your config settings.

module.exports = {

  development: {
    client: 'postgresql',
    connection: {
      database: 'todo',
      user: 'yoonghm'
    },
    pool: {
      min: 2,
      max: 10
    }
  }
};
rclai commented

Are you connected to the right database?

I figured out the reason by printing all attributes from PG:

for (var x in PG) {
  if (typeof PG[x] != 'function')
    console.log(x);
}

One of the attribute, defaultConnectionUrl is suspicious. I looked it up and found it in .meteor/local/isopacks/simple_pg/os/pg.js

PG.defaultConnectionUrl = process.env.POSTGRESQL_URL || 'postgres://127.0.0.1/postgres';

The run-app.sh set the value to "postgres://127.0.0.1/todos".

So now the new question is why the information in .knex/knexfile.js is not used?

rclai commented

Because it's only used for migrations via Knex.

http://knexjs.org/#knexfile

You need to export POSTGRESQL_URL the same way you would export the MONGO_URL.

Thanks. From http://knexjs.org/, I still do not see why migrations is needed. Could you help to explain? Thanks.

rclai commented

You can read this Wikipedia article about migrations to get the gist of it.

Thanks!