#!/usr/bin/env bash # Retira exclusivamente el esquema vacío fewp1 de CDMON. # Por defecto solo hace dry-run. La eliminación real exige --apply y el token exacto. set -euo pipefail mode="dry-run" if [[ "${1:-}" == "--apply" ]]; then mode="apply" fi if [[ "$mode" == "apply" && "${CONFIRM_DROP_FEWP1:-}" != "DROP_FEWP1" ]]; then echo "Refusing apply: export CONFIRM_DROP_FEWP1=DROP_FEWP1 first." >&2 exit 2 fi set -a source "$HOME/.hermes/profiles/feadulta/.env" set +a php='global $wpdb; $count=(int)$wpdb->get_var("SELECT COUNT(*) FROM information_schema.tables WHERE table_schema=\"fewp1\""); if ($count !== 0) { fwrite(STDERR, "ABORT: fewp1 has ".$count." tables; it is not empty.\n"); exit(3); } echo "PASS: fewp1 exists and has 0 tables.\n";' if [[ "$mode" == "apply" ]]; then php+=' $ok=$wpdb->query("DROP DATABASE `fewp1`"); if ($ok === false) { fwrite(STDERR, "ABORT: DROP DATABASE failed.\n"); exit(4); } $remaining=(int)$wpdb->get_var("SELECT COUNT(*) FROM information_schema.schemata WHERE schema_name=\"fewp1\""); if ($remaining !== 0) { fwrite(STDERR, "ABORT: fewp1 remains after DROP.\n"); exit(5); } echo "APPLIED: fewp1 removed; verified absent.\n";' else php+=' echo "DRY-RUN: would execute DROP DATABASE `fewp1`; no production change made.\n";' fi printf -v quoted_php '%q' "$php" sshpass -p "$FEA_PROD_SSH_PASS" ssh -o StrictHostKeyChecking=accept-new "$FEA_PROD_SSH_HOST" \ "cd /web && wp eval $quoted_php"