Reputation: 560
In Firefox. Init (once)
var r, dbname = 'a1', db = mozIndexedDB;
First,
try { r = db.open(dbname, 5); } catch (ex) { console.log(ex); }
r.onupgradeneeded = r.onsuccess = r.onblocked = r.onerror = function (e) { console.log(e); };
you get two events fired as supposed to be. Then close the database,
r.result.close()
Finally, delete the database,
try { r = db.deleteDatabase(dbname); } catch (ex) { console.log(ex); }
r.onsuccess = r.onerror = r.onblocked = function (e) { console.log(e); };
deletes successfully. However when I start running the first step scrip (opening db), 'onupgradeneeded' does not get fired and opens database with version it had before it was deleted. Is it bug, or am I doing smth wrong?
Thanks.
Upvotes: 1
Views: 1760
Reputation: 29208
You don't seem to be doing anything wrong. For what it's worth, I believe the deleteDatabase
implementation is relatively new in FF so perhaps you've found a bug.
One thing I would try is to first inspect and then physically remove the IndexeDB-backing .sqlite database files before restarting the browser. It could be a caching thing. Paths to those files below.
On a PC:
C:\Users\username\AppData\Roaming\Mozilla\Firefox\Profiles\<*>.default\indexedDB
On a Mac:
/Users/username/Library/Application\ Support/Firefox/Profiles/<*>.default/indexedDB/
The table in the .sqlite file that has the database version is called database
, and there are two columns, name and version. Your database should be in that table and should list the version number.
Deleting the database should delete that row. If it doesn't, I believe you've found a bug.
Worst comes to worse, delete the entire directory in the indexedDB
profile folder and reinstall to verify a fresh install works.
Upvotes: 1