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:
@@ -8,7 +8,7 @@ async function createLinkAttempt(OAuth2LinkId, playerUuid) {
|
||||
VALUES (?, ?)
|
||||
ON DUPLICATE KEY UPDATE playerUuid = VALUES(playerUuid), createdAt = NOW()
|
||||
`
|
||||
const result = await database.query(sql, [OAuth2LinkId, playerUuid])
|
||||
const result = await database.pool.query(sql, [OAuth2LinkId, playerUuid])
|
||||
return result.affectedRows > 0
|
||||
} catch (error) {
|
||||
return utils.handleDBError(error)
|
||||
@@ -18,14 +18,14 @@ async function createLinkAttempt(OAuth2LinkId, playerUuid) {
|
||||
async function popLinkAttempt(OAuth2LinkId) {
|
||||
try {
|
||||
const selectSql = "SELECT playerUuid FROM oaauth2LinkAttempts WHERE OAuth2LinkId = ?"
|
||||
const rows = await database.query(selectSql, [OAuth2LinkId])
|
||||
const rows = await database.pool.query(selectSql, [OAuth2LinkId])
|
||||
|
||||
if (rows.length === 0) return null
|
||||
|
||||
const playerUuid = rows[0].playerUuid
|
||||
|
||||
const deleteSql = "DELETE FROM oaauth2LinkAttempts WHERE OAuth2LinkId = ?"
|
||||
await database.query(deleteSql, [OAuth2LinkId])
|
||||
await database.pool.query(deleteSql, [OAuth2LinkId])
|
||||
|
||||
return playerUuid
|
||||
} catch (error) {
|
||||
@@ -36,7 +36,7 @@ async function popLinkAttempt(OAuth2LinkId) {
|
||||
async function unlinkProviderAccount(provider, playerUuid) {
|
||||
try {
|
||||
const sql = `DELETE FROM playersProperties WHERE name = '${provider}Id' AND uuid = ?`
|
||||
const result = await database.query(sql, [playerUuid])
|
||||
const result = await database.pool.query(sql, [playerUuid])
|
||||
|
||||
return result.affectedRows > 0
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user