We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

IDBVersionChangeEvent.oldVersion

The oldVersion read-only property of the IDBVersionChangeEvent interface returns the old version number of the database.

When the opened database doesn't exist yet, the value of oldVersion is 0.

Note: This feature is available in Web Workers.

Syntax

var oldVersion = IDBVersionChangeEvent.oldVersion

Value

A 64-bit integer.

Example

var dbName = "sampleDB";
var dbVersion = 2;
var request = indexedDB.open(dbName, dbVersion);

request.onupgradeneeded = function(e) {
  var db = request.result;
  if (e.oldVersion < 1) {
    db.createObjectStore("store1");
  }

  if (e.oldVersion < 2) {
    db.deleteObjectStore("store1");
    db.createObjectStore("store2");
  }

  // etc. for version < 3, 4...
};

Specifications

Specification Status Comment
Indexed Database API
The definition of 'oldVersion' in that specification.
Recommendation  
Indexed Database API 2.0
The definition of 'oldVersion' in that specification.
Recommendation  

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support

24

23 — 57 webkit

12

16

10 — 16 moz

101157
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support

24

23 — 57 webkit

24

23 — 57 webkit

Yes22228

Yes

Yes — 7.0 webkit

1. partial

See also

Document Tags and Contributors

Contributors to this page: fscholz, jpmedley, chrisdavidmills, libbymc
Last updated by: fscholz,