Add DDL-based DB init and bootstrap
Add bootstrap entrypoint and migrate DB schema setup to SQL files. Introduces bootstrap.js, many data/ddl/*.sql files, and a new runDDL() in modules/database.js (exports pool and runDDL). Remove legacy modules/databaseGlobals.js. Update repositories and code to use database.pool.query calls. Bump package version and set main to bootstrap.js. Clean up server.js to remove inline DB/cert init (now handled by bootstrap). Overall: refactor DB initialization to run ordered SQL DDL files and centralize startup logic.
This commit is contained in:
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
const certificates = require("./modules/certificatesManager")
|
||||
const database = require("./modules/database")
|
||||
const logger = require("./modules/logger")
|
||||
|
||||
async function boot() {
|
||||
try {
|
||||
await database.runDDL()
|
||||
certificates.setupKeys()
|
||||
require("./server")
|
||||
} catch (error) {
|
||||
if (error?.fatal) {
|
||||
logger.error("Fatal error while booting:", ["STARTUP", "cyan"])
|
||||
logger.error(error?.stack || error?.toString(), ["STARTUP", "cyan"])
|
||||
process.exit(1)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
boot()
|
||||
Reference in New Issue
Block a user