code: function migrateLocalStore(txn, cb) {
      var localStore = txn.objectStore(LOCAL_STORE);
      var docStore = txn.objectStore(DOC_STORE);
      var seqStore = txn.objectStore(BY_SEQ_STORE);
  
      var cursor = docStore.openCursor();
      cursor.onsuccess = function (event) {
        var cursor = event.target.result;
        if (cursor) {
          var metadata = cursor.value;
          var docId = metadata.id;
          var local = pouchdbMerge.isLocalId(docId);
          var rev = pouchdbMerge.winningRev(metadata);
          if (local) {
            var docIdRev = docId + "::" + rev;
            // remove all seq entries
            // associated with this docId
            var start = docId + "::";
            var end = docId + "::~";
            var index = seqStore.index('_doc_id_rev');
            var range = IDBKeyRange.bound(start, end, false, false);
            var seqCursor = index.openCursor(range);
            seqCursor.onsuccess = function (e) {
              seqCursor = e.target.result;
              if (!seqCursor) {
                // done
                docStore.delete(cursor.primaryKey);
                cursor.continue();
              } else {
                var data = seqCursor.value;
                if (data._doc_id_rev === docIdRev) {
                  localStore.put(data);
                }
                seqStore.delete(seqCursor.primaryKey);
                seqCursor.continue();
              }
            };
          } else {
            cursor.continue();
          }
        } else if (cb) {
          cb();
        }
      };
    }
docs: migration to version 3 (part 2)