17 lines
2.8 KiB
PHP
17 lines
2.8 KiB
PHP
<?php
|
|
require __DIR__.'/boot-QA.php';use Illuminate\Support\Facades\DB;
|
|
$before=json_decode(file_get_contents(dirname($source).'/baseline-QA.json'),true,512,JSON_THROW_ON_ERROR);$now=[];
|
|
DB::beginTransaction();DB::statement('SET TRANSACTION READ ONLY');
|
|
foreach(DB::select("SELECT tablename FROM pg_tables WHERE schemaname='public' ORDER BY tablename")as$t){$name=$t->tablename;$quoted='"'.str_replace('"','""',$name).'"';$now[$name]=DB::selectOne("SELECT md5(COALESCE(jsonb_agg(to_jsonb(t) ORDER BY to_jsonb(t)::text),'[]'::jsonb)::text) AS hash FROM $quoted t")->hash;}
|
|
$different=[];foreach($before['hashes']as$name=>$hash){if(($now[$name]??null)!==$hash)$different[]=$name;}
|
|
$unchangedZones=0;foreach($before['zones']as$old){if(in_array($old['code'],['MOZ-TOPUITO-PARK','MOZ-BELULUANE-PARK'],true))continue;$current=(array)DB::table('investment_zones')->where('id',$old['id'])->first();unset($current['editorial_draft']);if($current!==$old)throw new RuntimeException('Unrelated zone changed: '.$old['code']);$unchangedZones++;}
|
|
$b=App\Models\ExistingBusiness::findOrFail('172aa874-98fc-4bf6-b78f-d2e9a386d345');
|
|
$refs=DB::table('investment_zone_revisions')->whereIn('zone_id',['0ae14c9a-1adb-4ee7-8094-d5d54d4e75f1','1b57649a-f522-4cd5-8e97-32e82b6e1b37'])->orderBy('zone_id')->orderBy('version_no')->get(['zone_id','version_no','action','sha256']);
|
|
$support=json_decode(file_get_contents(__DIR__.'/SUPORTE-QA-CORRIGIDO.json'),true);$doc=DB::table('documents')->where('id',$support['source_document_id'])->first();
|
|
$result=['target'=>$target,'tables_before'=>count($before['hashes']),'tables_after'=>count($now),'unchanged_table_hashes'=>count($before['hashes'])-count($different),'changed_tables'=>$different,'unrelated_zones_identical'=>$unchangedZones,
|
|
'existing_businesses_table_unchanged'=>!in_array('existing_businesses',$different,true),'synthetic_execution_clone_business_version'=>$b->version_no,'synthetic_execution_clone_business_status'=>$b->status,'original_reference_v12_not_retested'=>true,'roles_unchanged'=>!in_array('portal_role_assignments',$different,true),'pair_unchanged'=>!in_array('portal_superuser_pair',$different,true),
|
|
'economic_reference_tables_unchanged'=>!array_intersect($different,['economic_activities','reference_catalog_versions','value_chains','value_chain_links','economic_clusters','sectors']),
|
|
'original_synthetic_document_hash_preserved'=>trim($doc->sha256)===$support['sha256'],'zone_revisions'=>$refs,'zone_count'=>DB::table('investment_zones')->count(),
|
|
'migration_only_once'=>DB::table('migrations')->where('migration',App\Services\InvestmentZoneOperationalProfile::MIGRATION)->count()===1];
|
|
DB::rollBack();file_put_contents(__DIR__.'/PRESERVACAO-QA.json',json_encode($result,JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE));echo json_encode(array_diff_key($result,['zone_revisions'=>true]),JSON_UNESCAPED_UNICODE);
|