title: SequelizeBaseError: column "..." does not exist
body: <p>Having trouble with an error using sequelize table joins 'belongTo' and 'hasMany;</p>
  
  <p><em>SequelizeBaseError: column videos.eventEventId does not exist.</em> </p>
  
  <p>I don't have this column in the model or db and haven't referenced anywhere in the router - not sure why this error is returned when i don't have this in my model or table?</p>
  
  <p>seems to be appear on any reference to the Primary key on the event model.</p>
  
  <pre><code>  const Sequelize = require('sequelize')   
  
    // Heroku postgres db connection
    const sequelize = new Sequelize(process.env.DATABASE_URL, {
        dialect: 'postgres',
        protocol: 'postgres',
        define: {
          timestamps: false,
         },
        dialectOptions: {
            ssl: true
        }
    });
  
    // Connect all the models/tables in the database to a db object,
    //so everything is accessible via one object
    const db = {};
  
    db.Sequelize = Sequelize;
    db.sequelize = sequelize;
  
    //Models/tables
    db.venues = require('./models/venue.js')(sequelize, Sequelize);
    db.events = require('./models/event.js')(sequelize, Sequelize);
    db.videos = require('./models/video.js')(sequelize, Sequelize);
  
    //Relations
    db.events.hasMany(db.videos);
    db.videos.belongsTo(db.events);
  
  
    module.exports = db;
  </code></pre>
  
  <p>models: event</p>
  
  <pre><code>  module.exports = (sequelize, DataTypes) =&gt; {
      const Event = sequelize.define('event', {
        id: {
          type: DataTypes.BIGINT,
          allowNull: false,
          autoIncrement: true,
          field: 'id',
        },
        venueId: {
          type: DataTypes.INTEGER,
          allowNull: true,
          references: {
            model: 'venue',
            key: 'id'
          },
          field: 'venue_id'
        },
        eventId: {
          type: DataTypes.TEXT,
          primaryKey: true,
          allowNull: true,
          field: 'event_id'
        },
        eventName: {
          type: DataTypes.TEXT,
          allowNull: true,
          field: 'event_name'
        },
        startTime: {
          type: DataTypes.TIME,
          allowNull: true,
          field: 'start_time'
        },
        place: {
          type: DataTypes.JSONB,
          allowNull: true,
          field: 'place'
        },
        loc: {
          type: DataTypes.GEOMETRY,
          allowNull: true,
          field: 'loc'
        },
        description: {
          type: DataTypes.TEXT,
          allowNull: true,
          field: 'description'
        },
        intelIsMusicEvent: {
          type: DataTypes.BOOLEAN,
          allowNull: true,
          field: 'intel_is_music_event'
        },
        intelHashTags: {
          type: 'ARRAY',
          allowNull: true,
          field: 'intel_hash_tags'
        },
        instaLocTag: {
          type: DataTypes.TEXT,
          allowNull: true,
          field: 'insta_loc_tag'
        },
        isEventOn: {
          type: DataTypes.BOOLEAN,
          allowNull: true,
          field: 'is_event_on'
        },
        videoCount: {
          type: DataTypes.BIGINT,
          allowNull: true,
          field: 'video_count'
        }
      }, {
        tableName: 'event'
      });
  
      return Event;
    };
  </code></pre>
  
  <p>video model</p>
  
  <pre><code>  module.exports = function(sequelize, DataTypes) {
      return sequelize.define('video', {
        eventId: {
          type: DataTypes.TEXT,
          allowNull: true,
          field: 'event_id',
          primaryKey: true,
        },
        userName: {
          type: DataTypes.TEXT,
          allowNull: true,
          field: 'user_name'
        },
        userPhotoLink: {
          type: DataTypes.TEXT,
          allowNull: true,
          field: 'user_photo_link'
        },
        instaVideoLink: {
          type: DataTypes.TEXT,
          allowNull: true,
          field: 'insta_video_link'
        },
  
      }, {
        tableName: 'insta_video'
      });
    };
  </code></pre>
  
  <p>router</p>
  
  <pre><code>    router.get('/venues/search', wrap(function*(req, res) {
             req.checkQuery('q', 'No keyword is specified').notEmpty().isAlpha()
             req.checkQuery('o', 'No keyword is specified').notEmpty().isInt() //o = offset of venue in db
  
     const result = yield req.getValidationResult()
  
     if (!result.isEmpty()) {
        res.status(400).json({
           status: 'error',
           errorMessage: result.array()
        })
     }
  
     try {
        const venues = yield db.events.findAll({
          include: [
                     {
                       model: db.videos,
                     }
                   ],
           raw: true,
           limit: 10,
           offset: `${req.query.o}`,
           order: [ [ 'video_count', 'DESC' ]],
           attributes: ['id', 'eventId', 'eventName', 'startTime', 'place', 'loc', 'description', 'instaLocTag', 'isEventOn', 'videoCount',],
           where: {
             'place.location.city': {
              $ilike: `%${req.query.q}%`
            },
            $or: {
              isEventOn:true
            }
          }
        })
  
        res.json({status: 'success', payload: venues})
     } catch (err) {
        console.log(err)
        console.trace(err)
     }
  
      })
    )
  
    module.exports = router
  </code></pre>