title: Sequelize: "Include unexpected" on associated table query
body: <p>Getting error with <code>documents</code> table include: </p>
  
  <p><code>Include unexpected. Element has to be either a Model, an Association or an object.</code>:</p>
  
  <pre><code>const users = await db.users.findAll({
      where: {
        profile_photo: { [Op.ne]: null },
      },
      include: [
        { 
          model: db.documents,
        }
      ],
  });
  </code></pre>
  
  <p>Relevant parts of <code>documents</code> define and association:</p>
  
  <pre><code>const document = sequelize.define(
      'document',
      {
        id: {
          allowNull: false,
          primaryKey: true,
          type: DataTypes.UUID,
          defaultValue: sequelize.literal('uuid_generate_v4()'),
        },
        user_id: {
          type: DataTypes.UUID,
          references: {
            model: 'users',
            key: 'id',
          },
        },
      }
    );
    document.associate = function(models) {
      models.document.belongsTo(models.users, {
        foreignKey: {
          name: 'user_id',
          allowNull: false,
        },
      });
    };
  </code></pre>
  
  <p>PSequel returns foreign key on documents table as:</p>
  
  <p>Key name: 
  <code>documents_user_id_fkey</code></p>
  
  <p>Columns:
  <code>user_id</code></p>
  
  <p>Foreign table:
  <code>users</code></p>
  
  <p>Foreign columns:
  <code>id</code></p>
  
  <p>And this psql query returns documents for user:</p>
  
  <pre><code>SELECT D
  FROM users U
  INNER JOIN documents D ON D.user_id = U.id
  </code></pre>
  
  <p>This query includes query DOES work though with <code>emails</code> table, and returns emails for user:</p>
  
  <pre><code>const users = await db.users.findAll({
      where: {
        profile_photo: { [Op.ne]: null },
      },
      include: [
        { 
          model: db.emails,
        }
      ],
  });
  </code></pre>
  
  <p>Relevant parts of <code>emails</code> define and association:</p>
  
  <pre><code>const Emails = sequelize.define(
      'emails',
      {
        id: {
          type: DataTypes.UUID,
          defaultValue: sequelize.literal('uuid_generate_v4()'),
          primaryKey: true,
        },
        user_id: {
          type: DataTypes.UUID,
          references: {
            model: 'users',
            key: 'id',
          },
          allowNull: false,
        },
    );
  
    Emails.associate = models =&gt; {
      models.emails.belongsTo(models.users, {
        onDelete: 'CASCADE',
        foreignKey: {
          name: 'user_id',
          allowNull: false,
        },
      });
    };
  </code></pre>
  
  <p>PSequel returns foreign key on <code>emails</code> table as:</p>
  
  <p>Key name: 
  <code>emails_user_id_fkey</code></p>
  
  <p>Columns:
  <code>user_id</code></p>
  
  <p>Foreign table:
  <code>users</code></p>
  
  <p>Foreign columns:
  <code>id</code></p>
  
  <p>Why isn't the <code>documents</code> table behaving the same as <code>emails</code>?</p>
  
  <p>Note: I did change the Sequelize association for Documents from name: <code>id</code> to <code>user_id</code> recently, do I need to re-init that association somehow? </p>
  
  <p>It was changed from:</p>
  
  <pre><code>    models.document.belongsTo(models.users, {
        foreignKey: {
          name: 'id',
          allowNull: false,
        },
      });
  </code></pre>
  
  <p>To:</p>
  
  <pre><code>    models.document.belongsTo(models.users, {
        foreignKey: {
          name: 'user_id',
          allowNull: false,
        },
      });
  </code></pre>