function alterObjectStores(
    name, objectStoreNames, func, handler, errorHandler) {
  var version = curVersion + 1;
  var openRequest = indexedDB.open(name, version);
  openRequest.onblocked = errorHandler;
  openRequest.onupgradeneeded = function(ev) {
    doAlteration(ev.target.transaction);
    // onsuccess will get called after this exits.
  };
  openRequest.onsuccess = function(ev) {
    assert(openRequest == ev.target);
    var db = openRequest.result;
    db.onerror = function(ev) {
      console.log("error altering db", arguments,
          openRequest.error.message);
      errorHandler();
    };
    if (db.version != version) {
      // This is the legacy path, which runs only in Chrome before M23.
      var setVersionRequest = db.setVersion(version);
      setVersionRequest.onerror = errorHandler;
      setVersionRequest.onsuccess =
          function(e) {
            curVersion = db.version;
            assert(setVersionRequest == e.target);
            var versionTransaction = setVersionRequest.result;
            versionTransaction.oncomplete = function() { handler(db); };
            versionTransaction.onerror = onError;
            doAlteration(versionTransaction);
          };
    } else {
      handler(db);
    }
  };
  function doAlteration(target) {
    for (var store in objectStoreNames) {
      func(target.objectStore(objectStoreNames[store]));
    }
  }
}
// You must close all database connections before calling this.
You must close all database connections before calling this.
You must close all database connections before calling this .
function alterObjectStores(
    name, objectStoreNames, func, handler, errorHandler) {
  var version = curVersion + 1;
  var openRequest = indexedDB.open(name, version);
  openRequest.onblocked = errorHandler;
  openRequest.onupgradeneeded = function(ev) {
    doAlteration(ev.target.transaction);
  };
  openRequest.onsuccess = function(ev) {
    assert(openRequest == ev.target);
    var db = openRequest.result;
    db.onerror = function(ev) {
      console.log("error altering db", arguments,
          openRequest.error.message);
      errorHandler();
    };
    if (db.version != version) {
      var setVersionRequest = db.setVersion(version);
      setVersionRequest.onerror = errorHandler;
      setVersionRequest.onsuccess =
          function(e) {
            curVersion = db.version;
            assert(setVersionRequest == e.target);
            var versionTransaction = setVersionRequest.result;
            versionTransaction.oncomplete = function() { handler(db); };
            versionTransaction.onerror = onError;
            doAlteration(versionTransaction);
          };
    } else {
      handler(db);
    }
  };
  function doAlteration(target) {
    for (var store in objectStoreNames) {
      func(target.objectStore(objectStoreNames[store]));
    }
  }
}
function alterObjectStores ( name , objectStoreNames , func , handler , errorHandler ) { var version = curVersion + 1 ; var openRequest = indexedDB . open ( name , version ) ; openRequest . onblocked = errorHandler ; openRequest . onupgradeneeded = function ( ev ) { doAlteration ( ev . target . transaction ) ; } ; openRequest . onsuccess = function ( ev ) { assert ( openRequest == ev . target ) ; var db = openRequest . result ; db . onerror = function ( ev ) { console . log ( "error altering db" , arguments , openRequest . error . message ) ; errorHandler ( ) ; } ; if ( db . version != version ) { var setVersionRequest = db . setVersion ( version ) ; setVersionRequest . onerror = errorHandler ; setVersionRequest . onsuccess = function ( e ) { curVersion = db . version ; assert ( setVersionRequest == e . target ) ; var versionTransaction = setVersionRequest . result ; versionTransaction . oncomplete = function ( ) { handler ( db ) ; } ; versionTransaction . onerror = onError ; doAlteration ( versionTransaction ) ; } ; } else { handler ( db ) ; } } ; function doAlteration ( target ) { for ( var store in objectStoreNames ) { func ( target . objectStore ( objectStoreNames [ store ] ) ) ; } } }
You must close all database connections before calling this.
You must close all database connections before calling this .
// onsuccess will get called after this exits. // This is the legacy path, which runs only in Chrome before M23.