chore: import DH V2 D5.6.4 production baseline
This commit is contained in:
Executable
+132
@@ -0,0 +1,132 @@
|
||||
#!/usr/bin/env bash
|
||||
set -Eeuo pipefail
|
||||
|
||||
ROOT="${ROOT:-/var/www/dhv2.korexlabs.com}"
|
||||
API_URL="${API_URL:-http://127.0.0.1:3101/api/v3}"
|
||||
TMP_MIGRATION="/tmp/dhv2-d538-accept-migration-$$.log"
|
||||
trap 'rm -f "$TMP_MIGRATION"' EXIT
|
||||
cd "$ROOT"
|
||||
|
||||
echo "========== D5.3.8 · VERSIONES =========="
|
||||
[[ "$(node -p "require('./api-v3/package.json').version")" == "0.19.3-8" ]]
|
||||
[[ "$(node -p "require('./web-v2/package.json').version")" == "0.19.3-8" ]]
|
||||
grep -Fq "API_PHASE = 'D5.3.8'" api-v3/src/version.ts
|
||||
echo "API: 0.19.3-8"
|
||||
echo "WEB: 0.19.3-8"
|
||||
|
||||
echo
|
||||
echo "========== D5.3.8 · DISCO Y DB =========="
|
||||
FREE_KB="$(df -Pk "$ROOT" | awk 'NR==2 {print $4}')"
|
||||
(( FREE_KB >= 2 * 1024 * 1024 ))
|
||||
[[ "$(docker inspect dhv2-db --format '{{.State.Health.Status}}')" == "healthy" ]]
|
||||
docker compose exec -T db sh -lc 'pg_isready -U "$POSTGRES_USER" -d "$POSTGRES_DB"'
|
||||
echo "Libre: $(( FREE_KB / 1024 / 1024 )) GB · PostgreSQL healthy"
|
||||
|
||||
echo
|
||||
echo "========== D5.3.8 · MIGRACIONES =========="
|
||||
docker compose --profile tools run --rm migrate npm run migration:show 2>&1 | tee "$TMP_MIGRATION"
|
||||
grep -Fq 'Pending migrations: no' "$TMP_MIGRATION"
|
||||
|
||||
echo
|
||||
echo "========== D5.3.8 · HEALTH =========="
|
||||
HEALTH="$(curl -fsS "$API_URL/health")"
|
||||
echo "$HEALTH"
|
||||
grep -Fq '"version":"0.19.3-8"' <<<"$HEALTH"
|
||||
grep -Fq '"phase":"D5.3.8"' <<<"$HEALTH"
|
||||
grep -Fq '"database":"ok"' <<<"$HEALTH"
|
||||
|
||||
echo
|
||||
echo "========== D5.3.8 · BACKUP INVENTARIO A REVISAR =========="
|
||||
if [[ -z "${STRONG_BACKUP:-}" ]]; then
|
||||
STRONG_BACKUP="$(find /root/DH_V2_BACKUPS -maxdepth 1 -type d -name 'INVENTARIO_A_REVISAR_*' -printf '%T@ %p\n' | sort -nr | head -n1 | cut -d' ' -f2-)"
|
||||
fi
|
||||
[[ -n "$STRONG_BACKUP" && -d "$STRONG_BACKUP" ]]
|
||||
test -s "$STRONG_BACKUP/INVENTARIO A REVISAR.txt"
|
||||
test -s "$STRONG_BACKUP/BACKUP_OK.txt"
|
||||
test -s "$STRONG_BACKUP/database.dump"
|
||||
test -s "$STRONG_BACKUP/source.tar.gz"
|
||||
test -s "$STRONG_BACKUP/asset-media.tar.gz"
|
||||
test -s "$STRONG_BACKUP/docker-images.tar.gz"
|
||||
test -s "$STRONG_BACKUP/SHA256SUMS.txt"
|
||||
grep -Fq 'INVENTARIO A REVISAR' "$STRONG_BACKUP/BACKUP_OK.txt"
|
||||
(
|
||||
cd "$STRONG_BACKUP"
|
||||
sha256sum -c SHA256SUMS.txt >/dev/null
|
||||
)
|
||||
echo "Backup fuerte validado: $STRONG_BACKUP"
|
||||
|
||||
echo
|
||||
echo "========== D5.3.8 · MODELO ESTRUCTURA LOCAL =========="
|
||||
DB_CHECK="$(
|
||||
cat <<'SQL' | docker compose exec -T db sh -c 'psql -U "$POSTGRES_USER" -d "$POSTGRES_DB" -At -v ON_ERROR_STOP=1'
|
||||
SELECT CASE WHEN EXISTS (SELECT 1 FROM typeorm_migrations WHERE name='PhaseD538LocalInventoryStructure1787853600000') THEN 'MIGRATION_D538_OK' ELSE 'MIGRATION_D538_BAD' END;
|
||||
SELECT CASE WHEN EXISTS (SELECT 1 FROM asset_types WHERE code='estructura_local' AND name='Estructura local (fuente)' AND operational_role='GENERIC' AND is_active=true) THEN 'LOCAL_TYPE_OK' ELSE 'LOCAL_TYPE_BAD' END;
|
||||
SELECT CASE WHEN (SELECT count(*) FROM asset_attribute_definitions d JOIN asset_types t ON t.id=d.asset_type_id WHERE t.code='estructura_local' AND d.code IN ('nivel_fuente','clasificacion_fuente','ruta_fuente') AND d.is_active=true)=3 THEN 'LOCAL_ATTRIBUTES_OK' ELSE 'LOCAL_ATTRIBUTES_BAD' END;
|
||||
SELECT CASE WHEN EXISTS (
|
||||
SELECT 1 FROM asset_type_parent_rules r
|
||||
JOIN asset_types child ON child.id=r.child_type_id
|
||||
JOIN asset_types parent ON parent.id=r.parent_type_id
|
||||
WHERE child.code='estructura_local' AND parent.code='yacimiento'
|
||||
) AND EXISTS (
|
||||
SELECT 1 FROM asset_type_parent_rules r
|
||||
JOIN asset_types child ON child.id=r.child_type_id
|
||||
JOIN asset_types parent ON parent.id=r.parent_type_id
|
||||
WHERE child.code='estructura_local' AND parent.code='area'
|
||||
) THEN 'LOCAL_PARENT_RULES_OK' ELSE 'LOCAL_PARENT_RULES_BAD' END;
|
||||
SELECT CASE WHEN EXISTS (
|
||||
SELECT 1 FROM pg_constraint
|
||||
WHERE conname='chk_asset_import_plan_item_kind'
|
||||
AND pg_get_constraintdef(oid) LIKE '%LOCAL_STRUCTURE%'
|
||||
) THEN 'PLAN_LOCAL_KIND_OK' ELSE 'PLAN_LOCAL_KIND_BAD' END;
|
||||
SQL
|
||||
)"
|
||||
echo "$DB_CHECK"
|
||||
grep -Fq 'MIGRATION_D538_OK' <<<"$DB_CHECK"
|
||||
grep -Fq 'LOCAL_TYPE_OK' <<<"$DB_CHECK"
|
||||
grep -Fq 'LOCAL_ATTRIBUTES_OK' <<<"$DB_CHECK"
|
||||
grep -Fq 'LOCAL_PARENT_RULES_OK' <<<"$DB_CHECK"
|
||||
grep -Fq 'PLAN_LOCAL_KIND_OK' <<<"$DB_CHECK"
|
||||
|
||||
echo
|
||||
echo "========== D5.3.8 · IMPORTADOR FLEXIBLE =========="
|
||||
grep -Fq 'sourceLocalStructureSuggestion' api-v3/src/asset-imports/asset-import-plan.ts
|
||||
grep -Fq "entityKind:'LOCAL_STRUCTURE'" api-v3/src/asset-imports/asset-imports.service.ts
|
||||
grep -Fq "assetTypeCode:'estructura_local'" api-v3/src/asset-imports/asset-imports.service.ts
|
||||
grep -Fq "classificationStatus:'SOURCE_PRESERVED'" api-v3/src/asset-imports/asset-imports.service.ts
|
||||
grep -Fq 'inventoryContextOverrides' api-v3/src/asset-imports/asset-imports.service.ts
|
||||
grep -Fq 'inventoryContextDecision:true' api-v3/src/asset-imports/asset-imports.service.ts
|
||||
grep -Fq 'PLAN_CONTEXT_DECISION_REQUIRED' api-v3/src/asset-imports/asset-imports.service.ts
|
||||
if grep -Fq '[A VALIDAR]' api-v3/src/asset-imports/asset-imports.service.ts; then
|
||||
echo "ERROR: D5.3.8 no debe inventar nombres [A VALIDAR]"; exit 1
|
||||
fi
|
||||
echo "Nomenclatura local preservada y ambigüedad territorial colapsada por causa raíz: OK"
|
||||
|
||||
echo
|
||||
echo "========== D5.3.8 · UI DE RESOLUCIÓN =========="
|
||||
grep -Fq 'Primero resolvé la causa raíz' web-v2/src/pages/AssetImportsPage.tsx
|
||||
grep -Fq 'Nomenclatura local preservada' web-v2/src/pages/AssetImportsPage.tsx
|
||||
grep -Fq 'Elegí el Área/Yacimiento correcto' web-v2/src/pages/AssetImportsPage.tsx
|
||||
grep -Fq 'inventoryContextCandidates' web-v2/src/pages/AssetImportsPage.tsx
|
||||
grep -Fq 'chooseContextCandidate' web-v2/src/pages/AssetImportsPage.tsx
|
||||
grep -Fq 'Se resuelve automáticamente después' web-v2/src/pages/AssetImportsPage.tsx
|
||||
grep -Fq 'Estructura local según fuente' web-v2/src/pages/AssetImportsPage.tsx
|
||||
grep -Fq 'import-context-candidates' web-v2/src/styles.css
|
||||
echo "Decisión raíz, alternativas territoriales y dependencias automáticas: OK"
|
||||
|
||||
echo
|
||||
echo "========== D5.3.8 · SEGURIDAD HEREDADA =========="
|
||||
grep -Fq 'private async masterStateFingerprint' api-v3/src/asset-imports/asset-imports.service.ts
|
||||
grep -Fq 'El Maestro cambió desde que se generó este plan' api-v3/src/asset-imports/asset-imports.service.ts
|
||||
grep -Fq 'applied_asset_id=$2::uuid,applied_object_id=($2::uuid)::text' api-v3/src/asset-imports/asset-imports.service.ts
|
||||
grep -Fq '::integer,$${base+2}::uuid' api-v3/src/asset-imports/asset-imports.service.ts
|
||||
echo "Plan stale, idempotencia, transacción y casteos seguros preservados: OK"
|
||||
|
||||
echo
|
||||
echo "========== D5.3.8 · CONTENEDORES =========="
|
||||
docker compose ps -a
|
||||
[[ "$(docker inspect dhv2-db --format '{{.State.Health.Status}}')" == "healthy" ]]
|
||||
[[ "$(docker inspect dhv2-api --format '{{.State.Status}}')" == "running" ]]
|
||||
[[ "$(docker inspect dhv2-web --format '{{.State.Status}}')" == "running" ]]
|
||||
|
||||
echo
|
||||
echo "ACEPTACIÓN DE FASE D5.3.8: OK"
|
||||
Reference in New Issue
Block a user