- Create abstract BaseMigration class with order, shouldRun(), migrate() - Add MigrationRunner to execute migrations in order - Add Migration v1→v2 (snmp → upsDevices) - Add Migration v3→v4 (upsList → upsDevices) - Update INupstConfig with version field - Update loadConfig() to run migrations automatically - Update saveConfig() to ensure version field and remove legacy fields - Update Docker test scripts to use real UPS data from .nogit/env.json - Remove colors.bright (not available in @std/fmt/colors) Config migrations allow users to jump versions (e.g., v1→v4) with all intermediate migrations running automatically. Version field tracks config format for future migrations.
60 lines
1.7 KiB
Bash
Executable File
60 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Test migration from v3 to v4
|
|
# Run this after 01-setup-v3-container.sh
|
|
#
|
|
|
|
set -e
|
|
|
|
CONTAINER_NAME="nupst-test-v3"
|
|
|
|
echo "================================================"
|
|
echo " NUPST v3 → v4 Migration Test"
|
|
echo "================================================"
|
|
echo ""
|
|
|
|
# Check if container exists
|
|
if ! docker ps --format '{{.Names}}' | grep -q "^${CONTAINER_NAME}$"; then
|
|
echo "❌ Container ${CONTAINER_NAME} is not running"
|
|
echo "Run ./01-setup-v3-container.sh first"
|
|
exit 1
|
|
fi
|
|
|
|
echo "→ Checking current NUPST status..."
|
|
docker exec ${CONTAINER_NAME} systemctl status nupst --no-pager || true
|
|
echo ""
|
|
|
|
echo "→ Checking current version..."
|
|
docker exec ${CONTAINER_NAME} nupst --version
|
|
echo ""
|
|
|
|
echo "→ Stopping v3 service..."
|
|
docker exec ${CONTAINER_NAME} systemctl stop nupst
|
|
echo ""
|
|
|
|
echo "→ Running v4 installation from main branch (should auto-detect v3 and migrate)..."
|
|
echo " Using: curl -sSL https://code.foss.global/serve.zone/nupst/raw/branch/main/install.sh | sudo bash"
|
|
docker exec ${CONTAINER_NAME} bash -c "
|
|
curl -sSL https://code.foss.global/serve.zone/nupst/raw/branch/main/install.sh | bash -s -- -y
|
|
"
|
|
|
|
echo "→ Checking service status after migration..."
|
|
docker exec ${CONTAINER_NAME} systemctl status nupst --no-pager || true
|
|
echo ""
|
|
|
|
echo "→ Checking new version..."
|
|
docker exec ${CONTAINER_NAME} nupst --version
|
|
echo ""
|
|
|
|
echo "→ Testing service commands..."
|
|
docker exec ${CONTAINER_NAME} nupst service status || true
|
|
echo ""
|
|
|
|
echo "================================================"
|
|
echo " ✓ Migration Test Complete"
|
|
echo "================================================"
|
|
echo ""
|
|
echo "Check logs with:"
|
|
echo " docker exec ${CONTAINER_NAME} nupst service logs"
|
|
echo ""
|