9 lines
1.9 KiB
PHP
9 lines
1.9 KiB
PHP
<?php
|
|
require __DIR__.'/boot-QA.php';
|
|
$base=new PDO('pgsql:host=127.0.0.1;port=55441;dbname=parks_operational_20261016_test','postgres','');if((int)$base->query('SELECT inet_server_port()')->fetchColumn()!==55441)throw new RuntimeException('QA reference only');
|
|
$baseline=json_decode(file_get_contents(__DIR__.'/BASELINE-QA.json'),true)['tables'];
|
|
foreach(['investment_zones','investment_zone_revisions']as$table){$h=$base->query('SELECT md5(COALESCE(string_agg(md5(row_to_json(t)::text),\'\' ORDER BY row_to_json(t)::text),\'\')) FROM "'.$table.'" t')->fetchColumn();if($h!==$baseline[$table])throw new RuntimeException('Reference drift');}
|
|
$old=$base->query("SELECT id,md5((to_jsonb(t)-'operational_details')::text) AS hash FROM investment_zones t ORDER BY id")->fetchAll(PDO::FETCH_KEY_PAIR);$new=Illuminate\Support\Facades\DB::select("SELECT id,md5((to_jsonb(t)-'operational_details')::text) AS hash FROM investment_zones t ORDER BY id");$count=0;foreach($new as$r){if($r->id==='0ae14c9a-1adb-4ee7-8094-d5d54d4e75f1')continue;if(($old[$r->id]??null)!==$r->hash)throw new RuntimeException('Other zone changed');$count++;}if(count($old)!==count($new))throw new RuntimeException('Zone created/deleted');
|
|
$old=$base->query('SELECT id,md5(row_to_json(t)::text) FROM investment_zone_revisions t')->fetchAll(PDO::FETCH_KEY_PAIR);$revisions=0;foreach($old as$id=>$hash){$r=Illuminate\Support\Facades\DB::selectOne('SELECT md5(row_to_json(t)::text) AS hash FROM investment_zone_revisions t WHERE id=?',[$id]);if(!$r||$r->hash!==$hash)throw new RuntimeException('Existing revision changed');$revisions++;}
|
|
$result=['reference_zone_and_revision_table_hashes_match_before_snapshot'=>true,'other_zones_preserved'=>$count,'existing_revisions_preserved'=>$revisions,'zone_count_unchanged'=>count($new),'new_master_records'=>0,'target'=>$target,'active_connections'=>0];file_put_contents(__DIR__.'/PRESERVACAO-QA.json',json_encode($result,JSON_PRETTY_PRINT));echo json_encode($result);
|