#!/bin/bash
set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"

echo "=== ScadaBridge Env2 Docker Teardown ==="

echo "Stopping env2 application containers..."
docker compose -f "$SCRIPT_DIR/docker-compose.yml" down

echo ""
echo "Teardown complete."
echo "Site data (SQLite DBs) and logs are preserved in node directories."
echo ""
echo "Env2 databases (ScadaBridgeConfig2 / ScadaBridgeMachineData2) remain on"
echo "the shared scadabridge-mssql. To drop them:"
echo "  docker exec scadabridge-mssql /opt/mssql-tools18/bin/sqlcmd \\"
echo "    -S localhost -U sa -P 'ScadaBridge_Dev1#' -C \\"
echo "    -Q \"DROP DATABASE ScadaBridgeConfig2; DROP DATABASE ScadaBridgeMachineData2;\""
