15 lines
3.7 KiB
PHP
15 lines
3.7 KiB
PHP
<?php
|
|
require __DIR__.'/boot-restored-QA.php';use Illuminate\Support\Facades\DB;
|
|
$original=new PDO('pgsql:host=127.0.0.1;port=55441;dbname=parks_operational_20261016_test','postgres','');
|
|
$restored=DB::connection()->getPdo();foreach([$original,$restored] as$p){$p->exec('BEGIN READ ONLY');if((int)$p->query('SELECT inet_server_port()')->fetchColumn()!==55441)throw new RuntimeException('QA only');}
|
|
$count=0;foreach($original->query("SELECT tablename FROM pg_tables WHERE schemaname='public' ORDER BY tablename")as$t){$name=$t['tablename'];$quoted='"'.str_replace('"','""',$name).'"';$sql="SELECT md5(COALESCE(jsonb_agg(to_jsonb(t) ORDER BY to_jsonb(t)::text),'[]'::jsonb)::text) FROM $quoted t";if($original->query($sql)->fetchColumn()!==$restored->query($sql)->fetchColumn())throw new RuntimeException('Restored rows differ');$count++;}
|
|
$seqs=0;foreach($original->query("SELECT sequencename FROM pg_sequences WHERE schemaname='public' ORDER BY sequencename")as$s){$sql='SELECT last_value,is_called FROM "'.str_replace('"','""',$s['sequencename']).'"';if($original->query($sql)->fetch(PDO::FETCH_ASSOC)!==$restored->query($sql)->fetch(PDO::FETCH_ASSOC))throw new RuntimeException('Restored sequence differs');$seqs++;}
|
|
foreach([$original,$restored]as$p)$p->exec('ROLLBACK');
|
|
$bel=App\Models\InvestmentZone::findOrFail('1b57649a-f522-4cd5-8e97-32e82b6e1b37');$draft=app(App\Services\InvestmentZoneOperationalProfile::class)->draft($bel);
|
|
$context=json_decode(file_get_contents(__DIR__.'/CONTEXTO-QA.json'),true);$case=DB::table('desk_cases')->where('id',$context['existing_case'])->first();$payload=app(App\Services\VirtualDesk::class)->decode($case->payload);
|
|
$kernel=$app->make(Illuminate\Contracts\Http\Kernel::class);$checks=[];
|
|
foreach(['/up','/api/v2/investment/zones/0ae14c9a-1adb-4ee7-8094-d5d54d4e75f1','/zonas/0ae14c9a-1adb-4ee7-8094-d5d54d4e75f1']as$path){$request=Illuminate\Http\Request::create($path,'GET',[],[],[],['HTTP_ACCEPT'=>'application/json']);$response=$kernel->handle($request);$checks[$path]=$response->getStatusCode();if($response->getStatusCode()!==200)throw new RuntimeException('Restored boot GET failed');$kernel->terminate($request,$response);}
|
|
$frozen=json_decode(file_get_contents(__DIR__.'/FROZEN-CANDIDATE.json'),true);foreach($frozen['sources']as$n=>$hash){if(hash_file('sha256',$source.'/'.$n)!==$hash)throw new RuntimeException('Restored final source mismatch');}foreach($frozen['build']as$n=>$hash){if(hash_file('sha256',$source.'/public/build/'.$n)!==$hash)throw new RuntimeException('Restored final build mismatch');}
|
|
$result=['target'=>$target,'tables_restored_equal'=>$count,'sequences_equal'=>$seqs,'new_draft_decrypts'=>$draft['working_version']===2,'new_optional_unknown_survives'=>$draft['fields']['resources'][0]['capacity_value']===null,'dossier_UUID_version_survives'=>$payload['investor_path']['zone_contexts'][0]['zone_id']==='0ae14c9a-1adb-4ee7-8094-d5d54d4e75f1' && $payload['investor_path']['zone_contexts'][0]['consulted_public_version']===5,'kernel_GETs'=>$checks,'active_changes'=>0,'scope'=>'Restored QA kernel/application/data/files; not active TLS/worker validation'];
|
|
$top=App\Models\InvestmentZone::findOrFail('0ae14c9a-1adb-4ee7-8094-d5d54d4e75f1');$latestDraft=app(App\Services\InvestmentZoneOperationalProfile::class)->draft($top);$result['final_post_use_draft_decrypts']=$latestDraft['working_version']===13 && $latestDraft['fields']['resources'][0]['private_note']==='QA-T2-PRIVADO-PRESERVAR';$result['final_candidate']=json_decode(file_get_contents(__DIR__.'/CANDIDATA.json'),true)['candidate'];$result['final_sources_and_build_verified']=count($frozen['sources'])+count($frozen['build']);file_put_contents(__DIR__.'/ARRANQUE-RESTAURO-QA.json',json_encode($result,JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE));echo json_encode($result);
|