add guard in init_DB, check for existing folder before db creation
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
This commit is contained in:
@@ -1,6 +1,15 @@
|
|||||||
import Database from 'better-sqlite3';
|
import Database from 'better-sqlite3';
|
||||||
|
import fs from 'fs';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
const db = new Database('./src/lib/data/tatort.db');
|
const fullPath = './src/lib/data/tatort.db';
|
||||||
|
const dir = path.dirname(fullPath);
|
||||||
|
|
||||||
|
if (!fs.existsSync(dir)) {
|
||||||
|
fs.mkdirSync(dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
const db = new Database(fullPath);
|
||||||
|
|
||||||
let createSQLStmt = `CREATE TABLE IF NOT EXISTS users
|
let createSQLStmt = `CREATE TABLE IF NOT EXISTS users
|
||||||
(id INTEGER PRIMARY KEY AUTOINCREMENT,
|
(id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
|||||||
Reference in New Issue
Block a user