B2G/gaia/apps/communications/dialer/js/call_log_db.js
/**
   * Upgrade schema to version 5. Add new 'emergency' and 'voicemail' bool
   * fields, to store whether a call was made to an emergency number or
   * to voicemail.
   *
   * param db
   *        Database instance.
   * param transaction
   *        IDB transaction instance.
   */
Upgrade schema to version 5. Add new 'emergency' and 'voicemail' bool
fields, to store whether a call was made to an emergency number or
to voicemail.

param db
Database instance.
param transaction
IDB transaction instance.
Upgrade schema to version 5 . Add new ' emergency ' and ' voicemail ' bool fields to store whether a call was made to an emergency number or to voicemail . param db Database instance . param transaction IDB transaction instance .
function upgradeSchemaVersion5(transaction, next) {
    this._newTxn('readwrite', [this._dbGroupsStore],
                 (function(error, txn, store) {
        if (error) {
          console.log('Error upgrading the database ' + error);
          return;
        }
        var groupsCount = 0;
        var groupsTotalCount = 0;
        var groupsProgress = 0;
        var groupsStore = txn.objectStore(this._dbGroupsStore);
        var performGroupsUpgrade = (function() {
          groupsStore.openCursor().onsuccess = (function(event) {
            var cursorGroups = event.target.result;
            if (!cursorGroups) {
              next();
              return;
            }
            var record = cursorGroups.value;
            record.emergency = false;
            record.voicemail = false;
            groupsStore.put(record);
            cursorGroups.continue();
            groupsCount += 1;
            groupsProgress =
              Math.round(((groupsCount / groupsTotalCount) * 100));
            this._notifyObservers('upgradeprogress', groupsProgress);
          }).bind(this);
        }).bind(this);
        groupsStore.count().onsuccess = function(event) {
          groupsTotalCount = event.target.result;
          performGroupsUpgrade();
        };
      }).bind(this)
    );
  }
function upgradeSchemaVersion5 ( transaction , next ) { this . _newTxn ( 'readwrite' , [ this . _dbGroupsStore ] , ( function ( error , txn , store ) { if ( error ) { console . log ( 'Error upgrading the database ' + error ) ; return ; } var groupsCount = 0 ; var groupsTotalCount = 0 ; var groupsProgress = 0 ; var groupsStore = txn . objectStore ( this . _dbGroupsStore ) ; var performGroupsUpgrade = ( function ( ) { groupsStore . openCursor ( ) . onsuccess = ( function ( event ) { var cursorGroups = event . target . result ; if ( ! cursorGroups ) { next ( ) ; return ; } var record = cursorGroups . value ; record . emergency = false ; record . voicemail = false ; groupsStore . put ( record ) ; cursorGroups . continue ( ) ; groupsCount += 1 ; groupsProgress = Math . round ( ( ( groupsCount / groupsTotalCount ) * 100 ) ) ; this . _notifyObservers ( 'upgradeprogress' , groupsProgress ) ; } ) . bind ( this ) ; } ) . bind ( this ) ; groupsStore . count ( ) . onsuccess = function ( event ) { groupsTotalCount = event . target . result ; performGroupsUpgrade ( ) ; } ; } ) . bind ( this ) ) ; }
Upgrade schema to version 5.
Upgrade schema to version 5 .