Files
Investidor-V2/outputs/investmoz-parques-QA-20261016/verify-original-history.php
T
nala cef6e201c7
tests / ci (push) Canceled after 0s
versao nrgocios 2
2026-10-16 20:11:05 +02:00

9 lines
1.2 KiB
PHP

<?php
require __DIR__.'/boot-QA.php';use Illuminate\Support\Facades\DB;
$origin=new PDO('pgsql:host=127.0.0.1;port=55441;dbname=economic_references_20261016_test','postgres','');$origin->exec('BEGIN READ ONLY');$origin->exec("SET LOCAL TIME ZONE 'UTC'");
if($origin->query('SELECT current_database()')->fetchColumn()!=='economic_references_20261016_test'||(int)$origin->query('SELECT inet_server_port()')->fetchColumn()!==55441)throw new RuntimeException('Exact reference QA only');
$old=$origin->query('SELECT id,md5(to_jsonb(t)::text) AS hash FROM investment_zone_revisions t ORDER BY id')->fetchAll(PDO::FETCH_ASSOC);$origin->exec('ROLLBACK');
$actual=collect(DB::select('SELECT id,md5(to_jsonb(t)::text) AS hash FROM investment_zone_revisions t ORDER BY id'))->pluck('hash','id');
foreach($old as$row){if($actual->get($row['id'])!==$row['hash'])throw new RuntimeException('An original revision was lost/changed');}
$proof=['target'=>$target,'reference'=>'economic_references_20261016_test:55441','original_revisions_preserved'=>count($old),'current_revision_count'=>$actual->count(),'append_only_history'=>true,'active_connections'=>0];file_put_contents(__DIR__.'/HISTORICO-PRESERVADO-QA.json',json_encode($proof,JSON_PRETTY_PRINT));echo json_encode($proof);