code: function migrateAttsAndSeqs(txn, callback) {
      var seqStore = txn.objectStore(BY_SEQ_STORE);
      var attStore = txn.objectStore(ATTACH_STORE);
      var attAndSeqStore = txn.objectStore(ATTACH_AND_SEQ_STORE);
  
      // need to actually populate the table. this is the expensive part,
      // so as an optimization, check first that this database even
      // contains attachments
      var req = attStore.count();
      req.onsuccess = function (e) {
        var count = e.target.result;
        if (!count) {
          return callback(); // done
        }
  
        seqStore.openCursor().onsuccess = function (e) {
          var cursor = e.target.result;
          if (!cursor) {
            return callback(); // done
          }
          var doc = cursor.value;
          var seq = cursor.primaryKey;
          var atts = Object.keys(doc._attachments || {});
          var digestMap = {};
          for (var j = 0; j < atts.length; j++) {
            var att = doc._attachments[atts[j]];
            digestMap[att.digest] = true; // uniq digests, just in case
          }
          var digests = Object.keys(digestMap);
          for (j = 0; j < digests.length; j++) {
            var digest = digests[j];
            attAndSeqStore.put({
              seq: seq,
              digestSeq: digest + '::' + seq
            });
          }
          cursor.continue();
        };
      };
    }
docs: migration to version 4 (part 2)