ci(F6.1): rehearse exact presentation territory baseline
This commit is contained in:
+21
-13
@@ -116,9 +116,9 @@ jobs:
|
|||||||
|
|
||||||
docker compose --env-file .env.example --profile tools run --rm migrate
|
docker compose --env-file .env.example --profile tools run --rm migrate
|
||||||
|
|
||||||
# F5.1 intentionally ends with zero operational/domain instances. The
|
# F5.1 performs the historical clean start. F6.1 then seeds only the
|
||||||
# technical family and finding masters remain, but territory preload,
|
# presentation territory approved by DH: 7 Departamentos, 64 Áreas,
|
||||||
# imports, applicability links and old audits are deliberately gone.
|
# 230 Yacimientos and 12 real Empresas.
|
||||||
docker compose --env-file .env.example exec -T db \
|
docker compose --env-file .env.example exec -T db \
|
||||||
psql -v ON_ERROR_STOP=1 -U dhv2_owner -d dhv2 <<'SQL'
|
psql -v ON_ERROR_STOP=1 -U dhv2_owner -d dhv2 <<'SQL'
|
||||||
DO $$
|
DO $$
|
||||||
@@ -128,6 +128,7 @@ jobs:
|
|||||||
audits integer;
|
audits integer;
|
||||||
applicability integer;
|
applicability integer;
|
||||||
territory_sources integer;
|
territory_sources integer;
|
||||||
|
presentation_sources integer;
|
||||||
source_installations integer;
|
source_installations integer;
|
||||||
source_subinstallations integer;
|
source_subinstallations integer;
|
||||||
source_findings integer;
|
source_findings integer;
|
||||||
@@ -149,18 +150,18 @@ jobs:
|
|||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
SELECT COUNT(*) INTO domain_assets FROM assets;
|
SELECT COUNT(*) INTO domain_assets FROM assets;
|
||||||
IF domain_assets <> 0 THEN
|
IF domain_assets <> 313 THEN
|
||||||
RAISE EXCEPTION 'F5.1 clean start must contain 0 Assets, got %', domain_assets;
|
RAISE EXCEPTION 'F6.1 presentation preload must contain 313 Assets, got %', domain_assets;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
SELECT COUNT(*) INTO audits FROM audit_events;
|
SELECT COUNT(*) INTO audits FROM audit_events;
|
||||||
IF audits <> 0 THEN
|
IF audits <> 0 THEN
|
||||||
RAISE EXCEPTION 'F5.1 clean start must contain 0 audit events, got %', audits;
|
RAISE EXCEPTION 'F6.1 presentation preload must start with 0 audit events, got %', audits;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
SELECT COUNT(*) INTO applicability FROM finding_catalog_item_inventory_families;
|
SELECT COUNT(*) INTO applicability FROM finding_catalog_item_inventory_families;
|
||||||
IF applicability <> 0 THEN
|
IF applicability <> 0 THEN
|
||||||
RAISE EXCEPTION 'F5.1 clean start must contain 0 finding applicability links, got %', applicability;
|
RAISE EXCEPTION 'Clean migration rehearsal must contain 0 finding applicability links, got %', applicability;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
SELECT COUNT(*) INTO territory_sources
|
SELECT COUNT(*) INTO territory_sources
|
||||||
@@ -170,13 +171,20 @@ jobs:
|
|||||||
RAISE EXCEPTION 'F5.1 must remove the old territory source preload, got % rows', territory_sources;
|
RAISE EXCEPTION 'F5.1 must remove the old territory source preload, got % rows', territory_sources;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
SELECT COUNT(*) INTO presentation_sources
|
||||||
|
FROM source_documents
|
||||||
|
WHERE document_number='DH-F6.1-PRESENTATION-TERRITORY-20260909';
|
||||||
|
IF presentation_sources <> 1 THEN
|
||||||
|
RAISE EXCEPTION 'F6.1 must contain exactly one presentation territory source, got %', presentation_sources;
|
||||||
|
END IF;
|
||||||
|
|
||||||
SELECT COUNT(*) FILTER (WHERE level='INSTALLATION'),
|
SELECT COUNT(*) FILTER (WHERE level='INSTALLATION'),
|
||||||
COUNT(*) FILTER (WHERE level='SUBINSTALLATION')
|
COUNT(*) FILTER (WHERE level='SUBINSTALLATION')
|
||||||
INTO source_installations,source_subinstallations
|
INTO source_installations,source_subinstallations
|
||||||
FROM inventory_families
|
FROM inventory_families
|
||||||
WHERE is_active=true AND source_reference LIKE 'F5:final_modelov2.xlsx%';
|
WHERE is_active=true AND source_reference LIKE 'F5:final_modelov2.xlsx%';
|
||||||
IF source_installations <> 14 OR source_subinstallations <> 109 THEN
|
IF source_installations <> 14 OR source_subinstallations <> 109 THEN
|
||||||
RAISE EXCEPTION 'F5.1 must preserve technical family masters: installations %, subinstallations %', source_installations,source_subinstallations;
|
RAISE EXCEPTION 'F6.1 must preserve technical family masters: installations %, subinstallations %', source_installations,source_subinstallations;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
SELECT COUNT(*) INTO source_findings
|
SELECT COUNT(*) INTO source_findings
|
||||||
@@ -184,7 +192,7 @@ jobs:
|
|||||||
JOIN finding_categories category ON category.id=item.category_id
|
JOIN finding_categories category ON category.id=item.category_id
|
||||||
WHERE lower(category.code)='f5model' AND item.is_active=true;
|
WHERE lower(category.code)='f5model' AND item.is_active=true;
|
||||||
IF source_findings <> 177 THEN
|
IF source_findings <> 177 THEN
|
||||||
RAISE EXCEPTION 'F5.1 must preserve finding master catalog, got %', source_findings;
|
RAISE EXCEPTION 'F6.1 must preserve finding master catalog, got %', source_findings;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
SELECT COUNT(*) INTO department_types
|
SELECT COUNT(*) INTO department_types
|
||||||
@@ -205,13 +213,13 @@ jobs:
|
|||||||
END $$;
|
END $$;
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
# F5.1 is intentionally one-way: production rollback is the PRE database
|
# Both destructive cuts are intentionally one-way: production rollback is
|
||||||
# backup, not migration:revert. Prove instead that the completed chain is
|
# the PRE database backup, not migration:revert. Prove the completed chain
|
||||||
# idempotent and has no pending migration on a second run.
|
# is idempotent and has no pending migration on a second run.
|
||||||
rerun_log="$(mktemp)"
|
rerun_log="$(mktemp)"
|
||||||
docker compose --env-file .env.example --profile tools run --rm migrate 2>&1 | tee "$rerun_log"
|
docker compose --env-file .env.example --profile tools run --rm migrate 2>&1 | tee "$rerun_log"
|
||||||
grep -Eq 'No pending migrations|Applied migrations: 0' "$rerun_log" || {
|
grep -Eq 'No pending migrations|Applied migrations: 0' "$rerun_log" || {
|
||||||
echo "ERROR: F5.1 migration chain is not idempotent." >&2
|
echo "ERROR: F6.1 migration chain is not idempotent." >&2
|
||||||
cat "$rerun_log" >&2
|
cat "$rerun_log" >&2
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user