Files
AzerothCore-RealmMaster/scripts/hooks/fix-beastmaster-sql
2025-11-02 18:08:17 -05:00

37 lines
953 B
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# Post-install hook to fix beastmaster SQL duplicate key issue
set -e
MODULE_DIR="${MODULE_DIR:-}"
MODULE_NAME="${MODULE_NAME:-}"
if [ -z "$MODULE_DIR" ] || [ ! -d "$MODULE_DIR" ]; then
echo "❌ fix-beastmaster-sql: Invalid module directory: $MODULE_DIR"
exit 2
fi
echo "🔧 fix-beastmaster-sql: Patching SQL file for $MODULE_NAME"
SQL_FILE="$MODULE_DIR/data/sql/db-world/beastmaster_tames_inserts.sql"
if [ ! -f "$SQL_FILE" ]; then
echo " SQL file not found, skipping: $SQL_FILE"
exit 0
fi
# Check if already patched
if grep -q "INSERT IGNORE INTO" "$SQL_FILE" 2>/dev/null; then
echo " ✅ SQL file already patched"
exit 0
fi
# Apply patch to make SQL idempotent
if sed -i 's/^INSERT INTO beastmaster_tames/INSERT IGNORE INTO beastmaster_tames/g' "$SQL_FILE"; then
echo " ✅ Patched SQL file to use INSERT IGNORE"
else
echo " ⚠️ Failed to patch SQL file"
exit 1
fi
exit 0