title: Adding table column with foreign key constraint using migrations in Sequelize
body: <p>I'm trying to add a user_id column with a foreign key contraint to a Todo-table in Node Express using Sequelize with Postgresql.
  I get an error message saying "Unhandled rejection SequelizeDatabaseError: column "UserId" does not exist". As you can see there is both "userId" and "UserId" in the SELECT query.
  <a href="https://i.stack.imgur.com/XSiUd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XSiUd.png" alt="&quot;Unhandled rejection SequelizeDatabaseError: column &quot;UserId&quot; does not exist&quot;"></a></p>
  
  <p>The SELECT query is built by a simple Todo.findAll().
  I believe it's something wrong in how I create the foreign key contraints in the migration file 20161116202040-add-user-id-to-todos.js</p>
  
  <pre><code>module.exports = {
    up: function (queryInterface, Sequelize) {
      return queryInterface.addColumn(
        'Todos',
        'userId', {
          type: Sequelize.INTEGER,
          references: {
            model: 'Users',
            key: 'id'}})},
  </code></pre>
  
  <p>The models/user.js looks like this: </p>
  
  <pre><code>module.exports = function(sequelize, DataTypes) {
    var User = sequelize.define('User', {
      email: DataTypes.STRING,
      password: DataTypes.STRING
    }, {
      classMethods: {
        associate: function(models) {
          User.hasMany(models.Todo);}}});
    return User;};
  </code></pre>
  
  <p>the models/todo.js looks like this:</p>
  
  <pre><code>module.exports = function(sequelize, DataTypes) {
    var Todo = sequelize.define('Todo', {
      name: DataTypes.STRING,
      userId: DataTypes.INTEGER
    },{  
      classMethods: {
        associate: function(models) {
          Todo.belongsTo(models.User); }}});
    return Todo;};
  </code></pre>