purge old database versions
This commit is contained in:
parent
80225a00d3
commit
9dfafe9d26
@ -20,16 +20,28 @@
|
||||
class Database {
|
||||
constructor() {
|
||||
this.db = null;
|
||||
this.dbVersion = 1;
|
||||
this.tagMetaCache = {};
|
||||
}
|
||||
|
||||
sanitize() {
|
||||
const db = new Dexie('dict');
|
||||
return db.open().then(() => {
|
||||
db.close();
|
||||
if (db.verno !== this.dbVersion) {
|
||||
return db.delete();
|
||||
}
|
||||
}).catch(() => {});
|
||||
}
|
||||
|
||||
prepare() {
|
||||
if (this.db !== null) {
|
||||
return Promise.reject('database already initialized');
|
||||
}
|
||||
|
||||
return this.sanitize().then(() => {
|
||||
this.db = new Dexie('dict');
|
||||
this.db.version(1).stores({
|
||||
this.db.version(this.dbVersion).stores({
|
||||
terms: '++id,dictionary,expression,reading',
|
||||
kanji: '++,dictionary,character',
|
||||
tagMeta: '++,dictionary',
|
||||
@ -37,6 +49,7 @@ class Database {
|
||||
});
|
||||
|
||||
return this.db.open();
|
||||
});
|
||||
}
|
||||
|
||||
purge() {
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"manifest_version": 2,
|
||||
"name": "Yomichan",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
|
||||
"description": "Japanese dictionary with Anki integration",
|
||||
"icons": {"16": "img/icon16.png", "48": "img/icon48.png", "128": "img/icon128.png"},
|
||||
|
Loading…
Reference in New Issue
Block a user