es2015/DBFactory.js
function upgradeDatabaseSchema(databaseName, event, migrationPromise,
    database, transaction, sortedSchemaDescriptors, migrationPromiseResolver,
    migrationPromiseRejector) {
  executeMigrationListeners(databaseName, event.oldVersion, event.newVersion,
      migrationPromise)
  
  let migrator = new DatabaseMigrator(
    database,
    transaction,
    sortedSchemaDescriptors,
    event.oldVersion
  )
  
  return PromiseSync.resolve().then(() => {
    return migrator.executeMigration()
  }).then(() => {
    migrationPromiseResolver()
  }).catch((error) => {
    migrationPromiseRejector(error)
    throw error
  })
}
function upgradeDatabaseSchema(databaseName, event, migrationPromise,
    database, transaction, sortedSchemaDescriptors, migrationPromiseResolver,
    migrationPromiseRejector) {
  executeMigrationListeners(databaseName, event.oldVersion, event.newVersion,
      migrationPromise)
  
  let migrator = new DatabaseMigrator(
    database,
    transaction,
    sortedSchemaDescriptors,
    event.oldVersion
  )
  
  return PromiseSync.resolve().then(() => {
    return migrator.executeMigration()
  }).then(() => {
    migrationPromiseResolver()
  }).catch((error) => {
    migrationPromiseRejector(error)
    throw error
  })
}
Handles the provided {@code upgradeneeded} event that occurred during
opening a database that was not blocked. The function handles database
schema upgrade.

@param {string} databaseName The name of the database to upgrade.
@param {Event} event The {@code upgradeneeded} event.
@param {Promise<undefined>} migrationPromise The database schema migration
promise to pass to the migration listeners.
@param {IDBDatabase} database The native Indexed DB database to upgrade.
@param {IDBTransaction} transaction The native {@code versionchange}
transaction to use to manipulate the data.
@param {(DatabaseSchema|UpgradedDatabaseSchema|Object)[]} sortedSchemaDescriptors
The database schema descriptors, sorted in ascending order by the
schema version number.
@param {function()} migrationPromiseResolver Schema migration promise
resolver.
@param {function(Error)} migrationPromiseRejector Schema migration promise
rejection callback.
@return {PromiseSync<undefined>} A promise resolved when the schema has been
upgraded.