mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2024-11-10 01:02:30 +01:00
Create DB form schema on start if config option is set
This commit is contained in:
parent
2cfe8964f3
commit
7acb19756b
2 changed files with 10 additions and 2 deletions
|
@ -8,6 +8,9 @@
|
|||
"behindProxy": true,
|
||||
"db": "./databases/sponsorTimes.db",
|
||||
"privateDB": "./databases/private.db",
|
||||
"createDatabaseIfNotExist": true, //depends on mode='development' //This will run on startup every time - so ensure "create table if not exists" is used in the schema
|
||||
"dbSchema": "./databases/_sponsorTimes.db.sql",
|
||||
"privateDBSchema": "./databases/_private.db.sql",
|
||||
"mode": "development",
|
||||
"readOnly": false
|
||||
}
|
5
index.js
5
index.js
|
@ -29,6 +29,11 @@ var db = new Sqlite3(config.db, options);
|
|||
//where the more sensitive data such as IP addresses are stored
|
||||
var privateDB = new Sqlite3(config.privateDB, options);
|
||||
|
||||
if (config.createDatabaseIfNotExist && (config.mode === "development")) {
|
||||
db.exec(fs.readFileSync(config.dbSchema).toString());
|
||||
privateDB.exec(fs.readFileSync(config.privateDBSchema).toString());
|
||||
}
|
||||
|
||||
// Create an HTTP service.
|
||||
http.createServer(app).listen(config.port);
|
||||
|
||||
|
|
Loading…
Reference in a new issue