1

I am trying to change database in a project running fine on MySQL to Postgres.
I receive the following error when running a migration (both with sync and sequelize db:migrate).

/myProject/node_modules/pg/lib/connection.js:109
      self.emit(msg.name, msg);
                   ^

TypeError: Cannot read property 'name' of undefined
    at Socket.<anonymous> (/myProject/node_modules/pg/lib/connection.js:109:20)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at readableAddChunk (_stream_readable.js:172:18)
    at Socket.Readable.push (_stream_readable.js:130:10)
    at TCP.onread (net.js:542:20)

I have isolated only this simple model, but I still get the error

module.exports = (sequelize, DataTypes) => {
  var User = sequelize.define('User', {
    email: {
      type: DataTypes.STRING,
      validate: {
        isEmail: true
      }
    },
    googleId: {
      type: DataTypes.STRING,
      allowNull: false
    }
  }, {
    underscored: true
  })

  return User
}

What could be the problem?

1
  • I doubt that is in your models. Can you paste your sequelize initialization code? Commented May 10, 2016 at 21:47

1 Answer 1

1

I had to change the connection string to this and now it works. Thanks.

var sequelize = new Sequelize(match[5], match[1], match[2], {
  dialect: 'postgres',
  protocol: 'postgres',
  port: match[4],
  host: match[3],
  logging: false,
  dialectOptions: {
    ssl: true
  }
})
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.