diff --git a/package-lock.json b/package-lock.json index 41923c2..5d8c8dc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8089,6 +8089,21 @@ "integrity": "sha512-VE0SOVEHCk7Qc8ulkWw3ntAzXuqf7S2lvwQaDLRnUeIEaKNQJzV6BwmLKhOqT61aGhfUMrXeaBk+oDGCzvhcug==", "dev": true }, + "sql-template-strings": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/sql-template-strings/-/sql-template-strings-2.2.2.tgz", + "integrity": "sha1-PxFQiiWt384hejBCqdMAwxk7lv8=", + "optional": true + }, + "sqlite": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/sqlite/-/sqlite-3.0.3.tgz", + "integrity": "sha512-DpofdtBibbiOObtdADGZYE6bvnLpjRG4ut/MDTDau2nK40htOLj1E0c55aOkvbnRVqQ0ZPtjj7PJuKKyS0Ypww==", + "requires": { + "sql-template-strings": "^2.2.2", + "sqlite3": "^4.0.0" + } + }, "sqlite3": { "version": "4.0.6", "resolved": "https://registry.npmjs.org/sqlite3/-/sqlite3-4.0.6.tgz", diff --git a/package.json b/package.json index b76f378..2b82f0c 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ "request": "^2.88.0", "scribe-js": "^2.0.4", "serve-static": "^1.13.2", + "sqlite": "^3.0.3", "sqlite3": "^4.0.2" }, "devDependencies": { diff --git a/server/db/database.js b/server/db/database.js index 6791326..79d69d6 100644 --- a/server/db/database.js +++ b/server/db/database.js @@ -48,6 +48,7 @@ async function applyMigrations(db) { } async function init() { + const sqlite = require('sqlite'); const SQLite3 = require('sqlite3'); const file = config.server.databaseFile; @@ -55,7 +56,7 @@ async function init() { let db; try { - db = new SQLite3.Database(file); + db = await sqlite.open(file); } catch (error) { Logger.tag('database').error('Error initialzing database:', error); @@ -72,7 +73,16 @@ async function init() { throw error; } - module.exports.db = db; + let legacyDB; + try { + legacyDB = new SQLite3.Database(file); + } + catch (error) { + Logger.tag('database').error('Error initialzing legacy database lib:', error); + throw error; + } + + module.exports.db = legacyDB; } module.exports = {