#!/bin/bash # Script to test WissKI table updates with data integrity checks. # This script exports data before update, runs the update, and verifies data integrity. set -e SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" cd "$SCRIPT_DIR" OUTPUT_DIR="$SCRIPT_DIR/wisski-data-integrity-test" TIMESTAMP=$(date +%Y%m%d_%H%M%S) echo "==========================================" echo "WissKI Table Update Data Integrity Test" echo "==========================================" echo "" # Step 1: Export data before update. echo "Step 1: Exporting data BEFORE update..." echo "----------------------------------------" php test-wisski-data-integrity.php export if [ ! -f "$OUTPUT_DIR/before-update-summary.json" ]; then echo "ERROR: Failed to export data before update!" exit 1 fi echo "" echo "✓ Data export complete. Backup saved to: $OUTPUT_DIR" echo "" read -p "Press Enter to continue with the update, or Ctrl+C to cancel..." # Step 2: Run Drupal updates. echo "" echo "Step 2: Running Drupal updates..." echo "----------------------------------------" # Check if drush is available. if command -v drush &> /dev/null; then echo "Running: drush updatedb -y" drush updatedb -y else echo "Drush not found. Please run Drupal updates manually:" echo " drush updatedb -y" echo "" read -p "Press Enter after you have run the updates, or Ctrl+C to cancel..." fi # Step 3: Verify data integrity. echo "" echo "Step 3: Verifying data integrity AFTER update..." echo "----------------------------------------" php test-wisski-data-integrity.php verify VERIFICATION_EXIT=$? echo "" if [ $VERIFICATION_EXIT -eq 0 ]; then echo "==========================================" echo "✓ SUCCESS: All data verified successfully!" echo "==========================================" else echo "==========================================" echo "⚠️ WARNING: Issues detected during verification!" echo "Check the verification report for details." echo "==========================================" fi echo "" echo "Test results saved to: $OUTPUT_DIR" echo "" exit $VERIFICATION_EXIT