- Add remove-test-agents.sh script - Integrate test agent removal into db-health-check.sh - Prevents test agents (ag_atlas, ag_oracle, ag_builder, ag_greeter) from reappearing
35 lines
1001 B
Bash
Executable File
35 lines
1001 B
Bash
Executable File
#!/bin/bash
|
|
# Remove test agents that should not exist
|
|
# Run this script after migrations or when test agents appear
|
|
|
|
set -e
|
|
|
|
echo "🧹 Removing test agents..."
|
|
|
|
# Database connection
|
|
DATABASE_URL="${DATABASE_URL:-postgresql://postgres:postgres@localhost:5432/daarion}"
|
|
|
|
# Test agent IDs that should never exist
|
|
TEST_AGENT_IDS=("ag_atlas" "ag_oracle" "ag_builder" "ag_greeter")
|
|
|
|
# Delete test agents
|
|
for agent_id in "${TEST_AGENT_IDS[@]}"; do
|
|
echo " Checking for: $agent_id"
|
|
docker exec daarion-postgres psql -U postgres -d daarion -c \
|
|
"DELETE FROM agents WHERE id = '$agent_id';" 2>&1 | grep -E "DELETE|0" || true
|
|
done
|
|
|
|
echo "✅ Test agents removed"
|
|
|
|
# Verify
|
|
COUNT=$(docker exec daarion-postgres psql -U postgres -d daarion -t -c \
|
|
"SELECT COUNT(*) FROM agents WHERE id IN ('ag_atlas', 'ag_oracle', 'ag_builder', 'ag_greeter');" 2>&1 | tr -d ' ')
|
|
|
|
if [ "$COUNT" -eq 0 ]; then
|
|
echo "✅ No test agents found"
|
|
else
|
|
echo "⚠️ Warning: $COUNT test agents still exist"
|
|
exit 1
|
|
fi
|
|
|