From b63092ab112d16966548fada84ac678cdcc3256b Mon Sep 17 00:00:00 2001 From: Samuel Zielke Date: Fri, 11 Oct 2024 00:13:58 +0200 Subject: [PATCH] BugFix: Update IndexDB --- app/static/app/js/dbcontrol.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/app/static/app/js/dbcontrol.js b/app/static/app/js/dbcontrol.js index 84fc104..213a69a 100644 --- a/app/static/app/js/dbcontrol.js +++ b/app/static/app/js/dbcontrol.js @@ -1,6 +1,6 @@ // IndexedDB Funktionen const dbName = 'myDB'; -const dbVersion = 1; +const dbVersion = 2; let db; @@ -17,15 +17,18 @@ function initDB() { request.onupgradeneeded = function (event) { db = event.target.result; - const store = db.createObjectStore('hours', { - keyPath: 'id', - autoIncrement: true, - }); - - const settingsT = db.createObjectStore('settings', { - keyPath: 'id', - autoIncrement: true, - }) + if (!db.objectStoreNames.contains('hours')) { + const store = db.createObjectStore('hours', { + keyPath: 'id', + autoIncrement: true, + }); + } + if (!db.objectStoreNames.contains('settings')) { + const settingsT = db.createObjectStore('settings', { + keyPath: 'id', + autoIncrement: true, + }) + } // Spalten definieren store.createIndex('createdate', 'createdate', { unique: false });