node-connect-pg-simple: error: relation "session" does not exist
After installing connect-pg-simple in my Drywall app, pg is complaining as such:
error: relation "session" does not exist
I’ve created the session table in the same database as the rest of my application uses, but I still get the above exception. I’ve also tried to specify the conString property, as such:
app.use(session({
  resave: true,
  saveUninitialized: true,
  secret: config.cryptoKey,
  store: new (require('connect-pg-simple')(session))(),
  cookie: { maxAge: 30 * 24 * 60 * 60 * 1000 }, // 30 days
  conString: 'pg://' + config.username + ':' + config.password + '@' + config.host + '/' + config.database
}));
But it doesn’t help. Ideas?
About this issue
- Original URL
 - State: closed
 - Created 9 years ago
 - Comments: 19 (6 by maintainers)
 
A note is included in the documentation that says it is necessary to create the session table yourself:
Though it is easy to overlook. I did at first 😃
You can either manually generate the table by executing it via
psql:Or you can create the table before creating your instance of
pgSession. Here’s an example using knex:The
conStringshould be sent intonew (require('connect-pg-simple')(session))()like:@asbjornu Just in case you haven’t seen it, there’s another project that is built specifically for Sequelize: https://www.npmjs.com/package/connect-session-sequelize
As of March 23 2021, this again has struck me!