Implement JQHTML function cache ID system and fix bundle compilation Implement underscore prefix for system tables Fix JS syntax linter to support decorators and grant exception to Task system SPA: Update planning docs and wishlists with remaining features SPA: Document Navigation API abandonment and future enhancements Implement SPA browser integration with History API (Phase 1) Convert contacts view page to SPA action Convert clients pages to SPA actions and document conversion procedure SPA: Merge GET parameters and update documentation Implement SPA route URL generation in JavaScript and PHP Implement SPA bootstrap controller architecture Add SPA routing manual page (rsx:man spa) Add SPA routing documentation to CLAUDE.md Phase 4 Complete: Client-side SPA routing implementation Update get_routes() consumers for unified route structure Complete SPA Phase 3: PHP-side route type detection and is_spa flag Restore unified routes structure and Manifest_Query class Refactor route indexing and add SPA infrastructure Phase 3 Complete: SPA route registration in manifest Implement SPA Phase 2: Extract router code and test decorators Rename Jqhtml_Component to Component and complete SPA foundation setup 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
65 lines
2.6 KiB
Bash
Executable File
65 lines
2.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# RSpade Test Database Reset Script
|
|
#
|
|
# Drops and recreates rspade_test database, then either:
|
|
# 1. Restores from snapshot (fast) + runs any new migrations
|
|
# 2. Runs all migrations from scratch (slow, if no snapshot exists)
|
|
#
|
|
# MUST be called from within test mode (after test_mode_enter)
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
SNAPSHOT_FILE="$SCRIPT_DIR/test_db_snapshot.sql"
|
|
|
|
# SAFETY CHECK: Ensure we're in test mode
|
|
if ! grep -q "^DB_DATABASE=rspade_test" /var/www/html/.env; then
|
|
echo "FATAL ERROR: db_reset.sh must be called from within test mode!" >&2
|
|
echo "" >&2
|
|
echo "Current database: $(grep "^DB_DATABASE=" /var/www/html/.env | cut -d= -f2)" >&2
|
|
echo "" >&2
|
|
echo "This is a safety check to prevent accidentally resetting the production database." >&2
|
|
echo "" >&2
|
|
echo "Correct usage:" >&2
|
|
echo " source /system/app/RSpade/tests/_lib/test_env.sh" >&2
|
|
echo " test_mode_enter" >&2
|
|
echo " _lib/db_reset.sh" >&2
|
|
echo " # ... run tests ..." >&2
|
|
echo " test_mode_exit" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if ! grep -q "^RSX_ADDITIONAL_CONFIG=.*rsx_test_config.php" /var/www/html/.env; then
|
|
echo "FATAL ERROR: Test config not loaded!" >&2
|
|
echo "" >&2
|
|
echo "RSX_ADDITIONAL_CONFIG must point to rsx_test_config.php when running tests." >&2
|
|
echo "This should be set automatically by test_mode_enter." >&2
|
|
echo "" >&2
|
|
echo "Current RSX_ADDITIONAL_CONFIG: $(grep "^RSX_ADDITIONAL_CONFIG=" /var/www/html/.env || echo 'NOT SET')" >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "[DB RESET] Dropping rspade_test database..." >&2
|
|
mysql -h127.0.0.1 -urspade -prspadepass -e "DROP DATABASE IF EXISTS rspade_test" 2>/dev/null
|
|
|
|
echo "[DB RESET] Creating rspade_test database..." >&2
|
|
mysql -h127.0.0.1 -urspade -prspadepass -e "CREATE DATABASE rspade_test CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci" 2>/dev/null
|
|
|
|
cd /var/www/html
|
|
|
|
if [ -f "$SNAPSHOT_FILE" ]; then
|
|
# Fast path: Restore from snapshot
|
|
echo "[DB RESET] Restoring from snapshot..." >&2
|
|
mysql -h127.0.0.1 -urspade -prspadepass rspade_test < "$SNAPSHOT_FILE" 2>/dev/null
|
|
|
|
# Run any new migrations that were added after snapshot
|
|
echo "[DB RESET] Running new migrations..." >&2
|
|
php artisan migrate --production 2>&1 | grep -v "Nothing to migrate" >&2
|
|
else
|
|
# Slow path: Run all migrations from scratch
|
|
echo "[DB RESET] No snapshot found, running all migrations..." >&2
|
|
echo "[DB RESET] (Create snapshot with: _lib/db_snapshot_create.sh)" >&2
|
|
php artisan migrate --production 2>&1 | grep -v "Nothing to migrate" >&2
|
|
fi
|
|
|
|
echo "[DB RESET] Database reset complete" >&2
|