module setup process

This commit is contained in:
uprightbass360
2025-11-17 02:23:53 -05:00
parent ea908dbbcf
commit d3484a3aea
30 changed files with 7685 additions and 430 deletions

View File

@@ -477,84 +477,11 @@ load_sql_helper(){
err "SQL helper not found; expected manage-modules-sql.sh to be available"
}
stage_module_sql_files(){
# Stage SQL files to AzerothCore's native update directory structure
# This replaces manual SQL execution with AzerothCore's built-in updater
local staging_dir="${MODULE_STAGING_DIR:-$MODULES_ROOT}"
local sql_manifest="$STATE_DIR/.sql-manifest.json"
if [ ! -f "$sql_manifest" ]; then
info "No SQL manifest found - no SQL files to stage"
return 0
fi
# Check if manifest has any modules with SQL
local module_count
module_count=$(python3 -c "import json; data=json.load(open('$sql_manifest')); print(len(data.get('modules', [])))" 2>/dev/null || echo "0")
if [ "$module_count" = "0" ]; then
info "No modules with SQL files to stage"
return 0
fi
info "Staging SQL for $module_count module(s)"
# Read each module from manifest and stage its SQL
local modules_json
modules_json=$(python3 -c "import json; data=json.load(open('$sql_manifest')); print('\n'.join(m['name'] for m in data['modules']))" 2>/dev/null || echo "")
if [ -z "$modules_json" ]; then
warn "Failed to parse SQL manifest"
return 1
fi
local staged_count=0
while IFS= read -r module_name; do
if [ -z "$module_name" ]; then
continue
fi
local module_path="$staging_dir/$module_name"
local acore_modules="/azerothcore/modules/$module_name"
if [ ! -d "$module_path" ]; then
warn "Module path not found: $module_path"
continue
fi
# Call stage-module-sql.sh for this module
local stage_script="${PROJECT_ROOT}/scripts/bash/stage-module-sql.sh"
if [ ! -f "$stage_script" ]; then
# Try container location
stage_script="/scripts/bash/stage-module-sql.sh"
fi
if [ -f "$stage_script" ]; then
if "$stage_script" \
--module-name "$module_name" \
--module-path "$module_path" \
--acore-path "$acore_modules"; then
((staged_count++))
fi
else
warn "SQL staging script not found: $stage_script"
fi
done <<< "$modules_json"
if [ "$staged_count" -gt 0 ]; then
ok "Staged SQL for $staged_count module(s)"
info "SQL will be applied by AzerothCore's updater on next server startup"
fi
return 0
}
execute_module_sql(){
# Legacy function - now calls staging instead of direct execution
SQL_EXECUTION_FAILED=0
stage_module_sql_files || SQL_EXECUTION_FAILED=1
}
# REMOVED: stage_module_sql_files() and execute_module_sql()
# These functions were part of build-time SQL staging that created files in
# /azerothcore/modules/*/data/sql/updates/ which are NEVER scanned by AzerothCore's DBUpdater.
# Module SQL is now staged at runtime by stage-modules.sh which copies files to
# /azerothcore/data/sql/updates/ (core directory) where they ARE scanned and processed.
track_module_state(){
echo 'Checking for module changes that require rebuild...'
@@ -655,18 +582,11 @@ main(){
remove_disabled_modules
install_enabled_modules
manage_configuration_files
info "SQL staging gate: MODULES_SKIP_SQL=${MODULES_SKIP_SQL:-0}"
if [ "${MODULES_SKIP_SQL:-0}" = "1" ]; then
info "Skipping module SQL staging (MODULES_SKIP_SQL=1)"
else
info "Staging module SQL files for AzerothCore updater"
execute_module_sql
fi
track_module_state
# NOTE: Module SQL staging is now handled at runtime by stage-modules.sh
# which copies SQL files to /azerothcore/data/sql/updates/ after containers start.
# Build-time SQL staging has been removed as it created files that were never processed.
if [ "${SQL_EXECUTION_FAILED:-0}" = "1" ]; then
warn "Module SQL execution reported issues; review logs above."
fi
track_module_state
echo 'Module management complete.'