title: sequelize - cannot read property catch of undefined
body: <p>I am using sequelize with mysql in my project. The current use case is about populating a table with 'roles_master' with some default roles. </p>
  
  <p>The function createDefaultRoles implementation checks:</p>
  
  <ul>
  <li>if there are rows in the table</li>
  <li>if yes, and force is true, deletes existing rows and inserts new rows </li>
  <li>if table empty, directly inserts new rows</li>
  </ul>
  
  <p>My code is as below...</p>
  
  <pre><code>/**
   *  Creates a pre-defined set of roles
   *  If roles table exists and already contains data, 
   *  this function simply returns, without creating any roles.
   *  The list of roles is defined in the file "ecp_db_defaults.js"
   *
   *  @param force -- boolean flag to indicate whether to drop existng roles and recreate afresh
   **/
  function createDefaultRoles(force, callback) {
    console.log("Executing createDefaultRoles...");
    db.Role.count().then(function(result) {
      if (result&gt;0) {
        if (force) {
          console.log("Emptying the roles table...");
          db.Role.destroy({force:true, where: {}}).then(function() {
            db.Role.bulkCreate(dbConfig.roles).done(function() {
              console.log("1. Successfully created user roles.");
              if (callback) return callback(null); else return;
            }).catch(function(e){
              console.log("Error while creating roles...", e);
              if (callback) return callback(e);
            });
          }).catch(function(e) {
            console.error("Error while destroying roles table.", e);
            return (callback)?callback(e):e;
          });
        }
        //if (callback) return callback(null); else return; 
      } else {
        db.Role.bulkCreate(dbConfig.roles).done(function(){
          console.log("2. Successfully created user roles.");
          if (callback) return callback(null);
        })
      }
    }).catch(function(e){
      console.error("Error while querying roles table.", e);
      if (callback) return callback(e);
    });
  }
  </code></pre>
  
  <p>The problem is that, it works partially.  While, it is able to delete the existing rows and add new ones, it also throws an exception which is caught and printed as below..</p>
  
  <ul>
  <li>Executing createDefaultRoles...  </li>
  <li>Emptying the roles table...  <strong>Error while destroying roles table. [TypeError: Cannot read property 'catch'of undefined</strong>]</li>
  <li><ol>
  <li>Successfully created user roles.</li>
  </ol></li>
  </ul>
  
  <p>Finally, the function fails, because of the above error.  I have tried matching all .then() and .catch() promises correctly.  They seem to be fine.</p>
  
  <p>Any help in solving this is highly appreciated.</p>