Edit database.js
parent
8213729009
commit
6f4a41fbd7
|
@ -18,7 +18,7 @@ async function executeQuery(query, values = []) {
|
||||||
return result.rows;
|
return result.rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function InitializeDatabase() {
|
async function Initialize() {
|
||||||
console.log("Initializing database...")
|
console.log("Initializing database...")
|
||||||
const sql = fs.readFileSync('database/init_database.sql').toString();
|
const sql = fs.readFileSync('database/init_database.sql').toString();
|
||||||
await executeQuery(sql);
|
await executeQuery(sql);
|
||||||
|
@ -35,7 +35,13 @@ async function checkForDatabaseInitialization() {
|
||||||
const scoresSchemaExists = result.length !== 0;
|
const scoresSchemaExists = result.length !== 0;
|
||||||
|
|
||||||
if(!scoresSchemaExists) {
|
if(!scoresSchemaExists) {
|
||||||
InitializeDatabase();
|
Initialize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
checkForDatabaseInitialization();
|
checkForDatabaseInitialization();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
exports.executeQuery = executeQuery;
|
Reference in New Issue